summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-05-06 11:28:22 -0700
committerChristopher Speller <crspeller@gmail.com>2016-05-06 14:28:22 -0400
commit6c75662b824491a20a757a5eec59556a866374b5 (patch)
tree2f531a680aaa45bc915d51764eb846bc1b80fa68 /model
parent4f799b980fd457e5dc97d2427a154576d7a5eded (diff)
downloadchat-6c75662b824491a20a757a5eec59556a866374b5.tar.gz
chat-6c75662b824491a20a757a5eec59556a866374b5.tar.bz2
chat-6c75662b824491a20a757a5eec59556a866374b5.zip
PLT-2697 Fixing team admins (#2900)
* PLT-2697 Fixing team admins * Fixing eslint error * Fixing loc issues * Fixing func * Fixing func
Diffstat (limited to 'model')
-rw-r--r--model/client.go4
-rw-r--r--model/team_member.go42
2 files changed, 44 insertions, 2 deletions
diff --git a/model/client.go b/model/client.go
index 54f143cfe..a74adcd7a 100644
--- a/model/client.go
+++ b/model/client.go
@@ -1023,7 +1023,7 @@ func (c *Client) UpdateUserRoles(data map[string]string) (*Result, *AppError) {
return nil, err
} else {
return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), UserFromJson(r.Body)}, nil
+ r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
}
}
@@ -1069,7 +1069,7 @@ func (c *Client) UpdateUserPassword(userId, currentPassword, newPassword string)
return nil, err
} else {
return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), UserFromJson(r.Body)}, nil
+ r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
}
}
diff --git a/model/team_member.go b/model/team_member.go
index 80ca9f2a3..ae687c109 100644
--- a/model/team_member.go
+++ b/model/team_member.go
@@ -58,6 +58,48 @@ func TeamMembersFromJson(data io.Reader) []*TeamMember {
}
}
+func IsValidTeamRoles(teamRoles string) bool {
+
+ roles := strings.Split(teamRoles, " ")
+
+ for _, r := range roles {
+ if !isValidTeamRole(r) {
+ return false
+ }
+ }
+
+ return true
+}
+
+func isValidTeamRole(role string) bool {
+ if role == "" {
+ return true
+ }
+
+ if role == ROLE_TEAM_ADMIN {
+ return true
+ }
+
+ return false
+}
+
+func IsInTeamRole(teamRoles string, inRole string) bool {
+ roles := strings.Split(teamRoles, " ")
+
+ for _, r := range roles {
+ if r == inRole {
+ return true
+ }
+
+ }
+
+ return false
+}
+
+func (o *TeamMember) IsTeamAdmin() bool {
+ return IsInTeamRole(o.Roles, ROLE_TEAM_ADMIN)
+}
+
func (o *TeamMember) IsValid() *AppError {
if len(o.TeamId) != 26 {