summaryrefslogtreecommitdiffstats
path: root/api/user.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-09-10 14:56:37 -0700
committer=Corey Hulen <corey@hulen.com>2015-09-10 14:56:37 -0700
commit8bf35081c80a56051037d0bc374e9fec3fb9529e (patch)
treedf5bad1c0b9448ed02b475125ed618b3872a5078 /api/user.go
parente54d0da392119e75788f3d5a431b85e931a7e824 (diff)
downloadchat-8bf35081c80a56051037d0bc374e9fec3fb9529e.tar.gz
chat-8bf35081c80a56051037d0bc374e9fec3fb9529e.tar.bz2
chat-8bf35081c80a56051037d0bc374e9fec3fb9529e.zip
PLT-12 UI framework for admin console
Diffstat (limited to 'api/user.go')
-rw-r--r--api/user.go31
1 files changed, 17 insertions, 14 deletions
diff --git a/api/user.go b/api/user.go
index 48f974dd5..0698ea2f0 100644
--- a/api/user.go
+++ b/api/user.go
@@ -985,22 +985,25 @@ func updateRoles(c *Context, w http.ResponseWriter, r *http.Request) {
func UpdateRoles(c *Context, user *model.User, roles string) *model.User {
// make sure there is at least 1 other active admin
- if model.IsInRole(user.Roles, model.ROLE_ADMIN) && !model.IsInRole(roles, model.ROLE_ADMIN) {
- if result := <-Srv.Store.User().GetProfiles(user.TeamId); result.Err != nil {
- c.Err = result.Err
- return nil
- } else {
- activeAdmins := -1
- profileUsers := result.Data.(map[string]*model.User)
- for _, profileUser := range profileUsers {
- if profileUser.DeleteAt == 0 && model.IsInRole(profileUser.Roles, model.ROLE_ADMIN) {
- activeAdmins = activeAdmins + 1
- }
- }
- if activeAdmins <= 0 {
- c.Err = model.NewAppError("updateRoles", "There must be at least one active admin", "")
+ if !model.IsInRole(roles, model.ROLE_SYSTEM_ADMIN) {
+ if model.IsInRole(user.Roles, model.ROLE_ADMIN) && !model.IsInRole(roles, model.ROLE_ADMIN) {
+ if result := <-Srv.Store.User().GetProfiles(user.TeamId); result.Err != nil {
+ c.Err = result.Err
return nil
+ } else {
+ activeAdmins := -1
+ profileUsers := result.Data.(map[string]*model.User)
+ for _, profileUser := range profileUsers {
+ if profileUser.DeleteAt == 0 && model.IsInRole(profileUser.Roles, model.ROLE_ADMIN) {
+ activeAdmins = activeAdmins + 1
+ }
+ }
+
+ if activeAdmins <= 0 {
+ c.Err = model.NewAppError("updateRoles", "There must be at least one active admin", "")
+ return nil
+ }
}
}
}