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

This commit is contained in:
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 BookEditor
//观察者 //观察者
BookObserver BookObserver
//未指定关系
BookRoleNoSpecific
) )
//项目角色 //项目角色

View File

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

View File

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

View File

@ -330,11 +330,11 @@ func (m *Member) Find(id int, cols ...string) (*Member, error) {
func (m *Member) ResolveRoleName() { func (m *Member) ResolveRoleName() {
if m.Role == conf.MemberSuperRole { 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 { } 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 { } 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 return members, 0, err
} }
for _, m := range members { for _, tm := range members {
m.ResolveRoleName() tm.Lang = m.Lang
tm.ResolveRoleName()
} }
return members, int(totalCount), nil 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) err := o.QueryTable(m.TableNameWithPrefix()).Filter("book_id", bookId).Filter("member_id", memberId).One(relationship)
if err != nil { if err != nil {
return conf.BookRoleNoSpecific, err
return 0, err
} }
return relationship.RoleId, nil return relationship.RoleId, nil
} }