summaryrefslogtreecommitdiffstats
path: root/api/user.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-09-23 15:52:59 -0700
committer=Corey Hulen <corey@hulen.com>2015-09-23 15:52:59 -0700
commit00112cae5123b02eee79e8b991618ed5069e07b1 (patch)
treeba8862900e2ed84bd7f3b720227448e05fe88efa /api/user.go
parent985aebf86120188c2a14adfab39af7c4da3c1c9d (diff)
downloadchat-00112cae5123b02eee79e8b991618ed5069e07b1.tar.gz
chat-00112cae5123b02eee79e8b991618ed5069e07b1.tar.bz2
chat-00112cae5123b02eee79e8b991618ed5069e07b1.zip
Assiging first user system_admin role
Diffstat (limited to 'api/user.go')
-rw-r--r--api/user.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/api/user.go b/api/user.go
index 2edbde3e2..3cce3cdd3 100644
--- a/api/user.go
+++ b/api/user.go
@@ -167,6 +167,19 @@ func CreateUser(c *Context, team *model.Team, user *model.User) *model.User {
if team.Email == user.Email {
user.Roles = model.ROLE_TEAM_ADMIN
channelRole = model.CHANNEL_ROLE_ADMIN
+
+ // Below is a speical case where the first user in the entire
+ // system is granted the system_admin role instead of admin
+ if result := <-Srv.Store.User().GetTotalUsersCount(); result.Err != nil {
+ c.Err = result.Err
+ return nil
+ } else {
+ count := result.Data.(int64)
+ if count <= 0 {
+ user.Roles = model.ROLE_SYSTEM_ADMIN
+ }
+ }
+
} else {
user.Roles = ""
}