Skip to content

Commit

Permalink
Fix bug in "chat-admin"
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Mar 10, 2024
1 parent 883572d commit dbbf737
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion controllers/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (c *ApiController) Signin() {
return
}

if !claims.IsAdmin {
if !claims.IsAdmin && claims.Type != "chat-admin" {
claims.Type = "chat-user"
}

Expand Down
12 changes: 6 additions & 6 deletions controllers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,22 @@ func (c *ApiController) CheckSignedIn() (string, bool) {
}

func (c *ApiController) RequireAdmin() bool {
user := c.GetSessionUser()
if user == nil || !user.IsAdmin {
if !c.IsAdmin() {
c.ResponseError("this operation requires admin privilege")
return true
return false
}

return false
return true
}

func (c *ApiController) IsAdmin() bool {
user := c.GetSessionUser()
if user == nil || !user.IsAdmin {
if user == nil {
return false
}

return true
res := user.IsAdmin || user.Type == "chat-admin"
return res
}

func DenyRequest(ctx *context.Context) {
Expand Down

0 comments on commit dbbf737

Please sign in to comment.