diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-09-14 08:58:53 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-09-14 08:58:53 -0400 |
commit | c3742aef71801544172cf77a46d52835594096a4 (patch) | |
tree | 76b3aacf1ee6da724201ea5411bef068cce3b26a /model/user.go | |
parent | 75721b5cb5ea19c1d6754adcc82891fa888fcacf (diff) | |
parent | 714f47e015adf4a455d29cbddfb5f58f84d9973e (diff) | |
download | chat-c3742aef71801544172cf77a46d52835594096a4.tar.gz chat-c3742aef71801544172cf77a46d52835594096a4.tar.bz2 chat-c3742aef71801544172cf77a46d52835594096a4.zip |
Merge pull request #648 from mattermost/PLT-12
PLT-12: Work in progress for Admin Console UI
Diffstat (limited to 'model/user.go')
-rw-r--r-- | model/user.go | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/model/user.go b/model/user.go index 05fc96953..fdc519b99 100644 --- a/model/user.go +++ b/model/user.go @@ -13,9 +13,8 @@ import ( ) const ( - ROLE_ADMIN = "admin" + ROLE_TEAM_ADMIN = "admin" ROLE_SYSTEM_ADMIN = "system_admin" - ROLE_SYSTEM_SUPPORT = "system_support" USER_AWAY_TIMEOUT = 5 * 60 * 1000 // 5 minutes USER_OFFLINE_TIMEOUT = 1 * 60 * 1000 // 1 minute USER_OFFLINE = "offline" @@ -272,6 +271,52 @@ func (u *User) GetDisplayName() string { } } +func IsValidRoles(userRoles string) bool { + + roles := strings.Split(userRoles, " ") + + for _, r := range roles { + if !isValidRole(r) { + return false + } + } + + return true +} + +func isValidRole(role string) bool { + if role == "" { + return true + } + + if role == ROLE_TEAM_ADMIN { + return true + } + + if role == ROLE_SYSTEM_ADMIN { + return true + } + + return false +} + +func (u *User) IsInRole(inRole string) bool { + return IsInRole(u.Roles, inRole) +} + +func IsInRole(userRoles string, inRole string) bool { + roles := strings.Split(userRoles, " ") + + for _, r := range roles { + if r == inRole { + return true + } + + } + + return false +} + func (u *User) PreExport() { u.Password = "" u.AuthData = "" |