summaryrefslogtreecommitdiffstats
path: root/api
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
parente54d0da392119e75788f3d5a431b85e931a7e824 (diff)
downloadchat-8bf35081c80a56051037d0bc374e9fec3fb9529e.tar.gz
chat-8bf35081c80a56051037d0bc374e9fec3fb9529e.tar.bz2
chat-8bf35081c80a56051037d0bc374e9fec3fb9529e.zip
PLT-12 UI framework for admin console
Diffstat (limited to 'api')
-rw-r--r--api/context.go3
-rw-r--r--api/user.go31
2 files changed, 19 insertions, 15 deletions
diff --git a/api/context.go b/api/context.go
index 2beea2408..1852ed4d6 100644
--- a/api/context.go
+++ b/api/context.go
@@ -285,7 +285,8 @@ func (c *Context) HasPermissionsToChannel(sc store.StoreChannel, where string) b
}
func (c *Context) IsSystemAdmin() bool {
- if model.IsInRole(c.Session.Roles, model.ROLE_SYSTEM_ADMIN) && IsPrivateIpAddress(c.IpAddress) {
+ // TODO XXX FIXME && IsPrivateIpAddress(c.IpAddress)
+ if model.IsInRole(c.Session.Roles, model.ROLE_SYSTEM_ADMIN) {
return true
}
return false
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
+ }
}
}
}