Assiging first user system_admin role

Этот коммит содержится в:
=Corey Hulen
2015-09-23 15:52:59 -07:00
родитель 985aebf861
Коммит 00112cae51
4 изменённых файлов: 51 добавлений и 0 удалений

Просмотреть файл

@@ -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 = ""
}