diff --git a/controllers/account.go b/controllers/account.go index 4ce2b7060..2ff8bcf6a 100644 --- a/controllers/account.go +++ b/controllers/account.go @@ -58,7 +58,7 @@ func (c *ApiController) Signin() { return } - if !claims.IsAdmin { + if !claims.IsAdmin && claims.Type != "chat-admin" { claims.Type = "chat-user" } diff --git a/controllers/util.go b/controllers/util.go index a582a6b4d..edc31ab8e 100644 --- a/controllers/util.go +++ b/controllers/util.go @@ -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) {