bugfix: 1. 用户管理,用户角色栏文本显示异常;2. 修复非book管理员且非评论作者,但是能删除评论的bug。

pull/806/head
Go-Go-Farther 2022-07-19 23:56:42 +08:00
parent 83bca4ac40
commit 1b47f0c372
5 changed files with 14 additions and 14 deletions

View File

@ -47,6 +47,8 @@ const (
BookEditor
//观察者
BookObserver
//未指定关系
BookRoleNoSpecific
)
//项目角色

View File

@ -99,8 +99,6 @@ func (c *DocumentController) Index() {
// CheckPassword : Handles password verification for private documents,
// and front-end requests are made through Ajax.
func (c *DocumentController) CheckPassword() {
c.Prepare()
identify := c.Ctx.Input.Param(":key")
password := c.GetString("bPassword")
@ -133,8 +131,6 @@ func (c *DocumentController) CheckPassword() {
// 阅读文档
func (c *DocumentController) Read() {
c.Prepare()
identify := c.Ctx.Input.Param(":key")
token := c.GetString("token")
id := c.GetString(":id")

View File

@ -46,12 +46,13 @@ func (c *ManagerController) Index() {
// 用户列表.
func (c *ManagerController) Users() {
c.Prepare()
c.TplName = "manager/users.tpl"
c.Data["Action"] = "users"
pageIndex, _ := c.GetInt("page", 0)
members, totalCount, err := models.NewMember().FindToPager(pageIndex, conf.PageSize)
tempMember := models.NewMember()
tempMember.Lang = c.Lang
members, totalCount, err := tempMember.FindToPager(pageIndex, conf.PageSize)
if err != nil {
c.Data["ErrorMessage"] = err.Error()
return
@ -78,7 +79,6 @@ func (c *ManagerController) Users() {
// 添加用户.
func (c *ManagerController) CreateMember() {
c.Prepare()
account := strings.TrimSpace(c.GetString("account"))
password1 := strings.TrimSpace(c.GetString("password1"))
@ -120,6 +120,8 @@ func (c *ManagerController) CreateMember() {
member.CreateAt = c.Member.MemberId
member.Email = email
member.RealName = strings.TrimSpace(c.GetString("real_name", ""))
member.Lang = c.Lang
if phone != "" {
member.Phone = phone
}

View File

@ -330,11 +330,11 @@ func (m *Member) Find(id int, cols ...string) (*Member, error) {
func (m *Member) ResolveRoleName() {
if m.Role == conf.MemberSuperRole {
m.RoleName = i18n.Tr(m.Lang, "common.administrator")
m.RoleName = i18n.Tr(m.Lang, "uc.super_admin")
} else if m.Role == conf.MemberAdminRole {
m.RoleName = i18n.Tr(m.Lang, "common.editor")
m.RoleName = i18n.Tr(m.Lang, "uc.admin")
} else if m.Role == conf.MemberGeneralRole {
m.RoleName = i18n.Tr(m.Lang, "common.obverser")
m.RoleName = i18n.Tr(m.Lang, "uc.user")
}
}
@ -385,8 +385,9 @@ func (m *Member) FindToPager(pageIndex, pageSize int) ([]*Member, int, error) {
return members, 0, err
}
for _, m := range members {
m.ResolveRoleName()
for _, tm := range members {
tm.Lang = m.Lang
tm.ResolveRoleName()
}
return members, int(totalCount), nil
}

View File

@ -100,8 +100,7 @@ func (m *Relationship) FindForRoleId(bookId, memberId int) (conf.BookRole, error
err := o.QueryTable(m.TableNameWithPrefix()).Filter("book_id", bookId).Filter("member_id", memberId).One(relationship)
if err != nil {
return 0, err
return conf.BookRoleNoSpecific, err
}
return relationship.RoleId, nil
}