From f5fec3a157e6c9146a0c4e28dd5f70e6c066affd Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Fri, 28 Aug 2015 08:37:55 -0400 Subject: Added the ability to create a team with SSO services and added the ability to turn off email sign up. --- api/user.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'api/user.go') diff --git a/api/user.go b/api/user.go index 05ccd03e8..3796dde2a 100644 --- a/api/user.go +++ b/api/user.go @@ -58,6 +58,11 @@ func InitUser(r *mux.Router) { } func createUser(c *Context, w http.ResponseWriter, r *http.Request) { + if !utils.Cfg.ServiceSettings.AllowEmailSignUp { + c.Err = model.NewAppError("signupTeam", "User sign-up with email is disabled.", "") + c.Err.StatusCode = http.StatusNotImplemented + return + } user := model.UserFromJson(r.Body) @@ -181,7 +186,7 @@ func CreateUser(c *Context, team *model.Team, user *model.User) *model.User { if result := <-Srv.Store.User().Save(user); result.Err != nil { c.Err = result.Err - l4g.Error("Filae err=%v", result.Err) + l4g.Error("Couldn't save the user err=%v", result.Err) return nil } else { ruser := result.Data.(*model.User) @@ -1426,3 +1431,18 @@ func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser } } + +func IsUsernameTaken(name string, teamId string) bool { + + if !model.IsValidUsername(name) { + return false + } + + if result := <-Srv.Store.User().GetByUsername(teamId, name); result.Err != nil { + return false + } else { + return true + } + + return false +} -- cgit v1.2.3-1-g7c22