summaryrefslogtreecommitdiffstats
path: root/api/team.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-09-04 11:59:10 -0700
committer=Corey Hulen <corey@hulen.com>2015-09-04 11:59:10 -0700
commit58d0d9afd286afd715e9f04825e1305045d404e2 (patch)
tree10615aa68c68106684503fb18ae4e4ef8998bc22 /api/team.go
parent05d95d80a896d14474c7f7384d67b9edd524b922 (diff)
downloadchat-58d0d9afd286afd715e9f04825e1305045d404e2.tar.gz
chat-58d0d9afd286afd715e9f04825e1305045d404e2.tar.bz2
chat-58d0d9afd286afd715e9f04825e1305045d404e2.zip
Adding cmd line options
Diffstat (limited to 'api/team.go')
-rw-r--r--api/team.go36
1 files changed, 22 insertions, 14 deletions
diff --git a/api/team.go b/api/team.go
index 8cce384c3..8c0be9486 100644
--- a/api/team.go
+++ b/api/team.go
@@ -239,47 +239,55 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) {
}
func createTeam(c *Context, w http.ResponseWriter, r *http.Request) {
+ team := model.TeamFromJson(r.Body)
+ rteam := CreateTeam(c, team)
+ if c.Err != nil {
+ return
+ }
+
+ w.Write([]byte(rteam.ToJson()))
+}
+
+func CreateTeam(c *Context, team *model.Team) *model.Team {
if utils.Cfg.ServiceSettings.DisableEmailSignUp {
c.Err = model.NewAppError("createTeam", "Team sign-up with email is disabled.", "")
c.Err.StatusCode = http.StatusNotImplemented
- return
+ return nil
}
- team := model.TeamFromJson(r.Body)
-
if team == nil {
c.SetInvalidParam("createTeam", "team")
- return
+ return nil
}
if !isTreamCreationAllowed(c, team.Email) {
- return
+ return nil
}
if utils.Cfg.ServiceSettings.Mode != utils.MODE_DEV {
- c.Err = model.NewAppError("createTeam", "The mode does not allow network creation without a valid invite", "")
- return
+ c.Err = model.NewAppError("CreateTeam", "The mode does not allow network creation without a valid invite", "")
+ return nil
}
if result := <-Srv.Store.Team().Save(team); result.Err != nil {
c.Err = result.Err
- return
+ return nil
} else {
rteam := result.Data.(*model.Team)
if _, err := CreateDefaultChannels(c, rteam.Id); err != nil {
c.Err = err
- return
+ return nil
}
if rteam.AllowValet {
CreateValet(c, rteam)
if c.Err != nil {
- return
+ return nil
}
}
- w.Write([]byte(rteam.ToJson()))
+ return rteam
}
}
@@ -467,7 +475,7 @@ func InviteMembers(c *Context, team *model.Team, user *model.User, invites []str
sender := user.GetDisplayName()
senderRole := ""
- if strings.Contains(user.Roles, model.ROLE_ADMIN) || strings.Contains(user.Roles, model.ROLE_SYSTEM_ADMIN) {
+ if model.IsInRole(user.Roles, model.ROLE_ADMIN) || model.IsInRole(user.Roles, model.ROLE_SYSTEM_ADMIN) {
senderRole = "administrator"
} else {
senderRole = "member"
@@ -526,7 +534,7 @@ func updateTeamDisplayName(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- if !strings.Contains(c.Session.Roles, model.ROLE_ADMIN) {
+ if !model.IsInRole(c.Session.Roles, model.ROLE_ADMIN) {
c.Err = model.NewAppError("updateTeamDisplayName", "You do not have the appropriate permissions", "userId="+c.Session.UserId)
c.Err.StatusCode = http.StatusForbidden
return
@@ -566,7 +574,7 @@ func updateValetFeature(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- if !strings.Contains(c.Session.Roles, model.ROLE_ADMIN) {
+ if !model.IsInRole(c.Session.Roles, model.ROLE_ADMIN) {
c.Err = model.NewAppError("updateValetFeature", "You do not have the appropriate permissions", "userId="+c.Session.UserId)
c.Err.StatusCode = http.StatusForbidden
return