diff options
author | Balasankar C <balasankarc@users.noreply.github.com> | 2018-05-18 19:27:30 +0530 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2018-05-18 09:57:30 -0400 |
commit | d3ead7dc8535f8fa5b175686cc1f7669c8b1648b (patch) | |
tree | ad6e0294e908f71c28f5fed1372c09b972e803a5 | |
parent | c6cbce610043bb050f2c542412eb439dc22c4a88 (diff) | |
download | chat-d3ead7dc8535f8fa5b175686cc1f7669c8b1648b.tar.gz chat-d3ead7dc8535f8fa5b175686cc1f7669c8b1648b.tar.bz2 chat-d3ead7dc8535f8fa5b175686cc1f7669c8b1648b.zip |
MM-10640 Set EnableUserCreation to true by default (#8815)
* Set EnableUserCreation to true by default
* Fix argument type to FormatBool
* Convert EnableUserCreation instances to pointer
* Convert to boolean in tests also
* Set value of pointer to be false
* Convert remaining EnableUserCreation instances to pointer
-rw-r--r-- | api4/oauth.go | 2 | ||||
-rw-r--r-- | api4/user_test.go | 10 | ||||
-rw-r--r-- | app/command_invite_people.go | 4 | ||||
-rw-r--r-- | app/diagnostics.go | 2 | ||||
-rw-r--r-- | app/user.go | 4 | ||||
-rw-r--r-- | app/user_test.go | 2 | ||||
-rw-r--r-- | model/config.go | 7 | ||||
-rw-r--r-- | utils/config.go | 2 |
8 files changed, 19 insertions, 14 deletions
diff --git a/api4/oauth.go b/api4/oauth.go index fa120ebbf..af3d83e17 100644 --- a/api4/oauth.go +++ b/api4/oauth.go @@ -563,7 +563,7 @@ func signupWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) { return } - if !c.App.Config().TeamSettings.EnableUserCreation { + if !*c.App.Config().TeamSettings.EnableUserCreation { utils.RenderWebError(w, r, http.StatusBadRequest, url.Values{ "message": []string{utils.T("api.oauth.singup_with_oauth.disabled.app_error")}, }, c.App.AsymmetricSigningKey()) diff --git a/api4/user_test.go b/api4/user_test.go index 5b4d8890a..4851f139e 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -63,7 +63,7 @@ func TestCreateUser(t *testing.T) { CheckBadRequestStatus(t, resp) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = false }) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = false }) + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = false }) user2 := &model.User{Email: th.GenerateTestEmail(), Password: "Password1", Username: GenerateTestUsername()} _, resp = AdminClient.CreateUser(user2) @@ -170,13 +170,13 @@ func TestCreateUserWithToken(t *testing.T) { <-th.App.Srv.Store.Token().Save(token) defer th.App.DeleteToken(token) - th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = false }) + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = false }) _, resp := Client.CreateUserWithToken(&user, token.Token) CheckNotImplementedStatus(t, resp) CheckErrorMessage(t, resp, "api.user.create_user.signup_email_disabled.app_error") - th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = true }) + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = true }) }) t.Run("EnableOpenServerDisable", func(t *testing.T) { @@ -270,7 +270,7 @@ func TestCreateUserWithInviteId(t *testing.T) { t.Run("EnableUserCreationDisable", func(t *testing.T) { user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID} - th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = false }) + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = false }) inviteId := th.BasicTeam.InviteId @@ -278,7 +278,7 @@ func TestCreateUserWithInviteId(t *testing.T) { CheckNotImplementedStatus(t, resp) CheckErrorMessage(t, resp, "api.user.create_user.signup_email_disabled.app_error") - th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = true }) + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = true }) }) t.Run("EnableOpenServerDisable", func(t *testing.T) { diff --git a/app/command_invite_people.go b/app/command_invite_people.go index e5ff5a316..c3dc4f469 100644 --- a/app/command_invite_people.go +++ b/app/command_invite_people.go @@ -28,7 +28,7 @@ func (me *InvitePeopleProvider) GetTrigger() string { func (me *InvitePeopleProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command { autoComplete := true - if !a.Config().EmailSettings.SendEmailNotifications || !a.Config().TeamSettings.EnableUserCreation { + if !a.Config().EmailSettings.SendEmailNotifications || !*a.Config().TeamSettings.EnableUserCreation { autoComplete = false } return &model.Command{ @@ -45,7 +45,7 @@ func (me *InvitePeopleProvider) DoCommand(a *App, args *model.CommandArgs, messa return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: args.T("api.command.invite_people.email_off")} } - if !a.Config().TeamSettings.EnableUserCreation { + if !*a.Config().TeamSettings.EnableUserCreation { return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: args.T("api.command.invite_people.invite_off")} } diff --git a/app/diagnostics.go b/app/diagnostics.go index fc8a2e886..6855731ce 100644 --- a/app/diagnostics.go +++ b/app/diagnostics.go @@ -244,7 +244,7 @@ func (a *App) trackConfig() { }) a.SendDiagnostic(TRACK_CONFIG_TEAM, map[string]interface{}{ - "enable_user_creation": cfg.TeamSettings.EnableUserCreation, + "enable_user_creation": *cfg.TeamSettings.EnableUserCreation, "enable_team_creation": *cfg.TeamSettings.EnableTeamCreation, "restrict_team_invite": *cfg.TeamSettings.RestrictTeamInvite, "restrict_public_channel_creation": *cfg.TeamSettings.RestrictPublicChannelCreation, diff --git a/app/user.go b/app/user.go index 2ee410684..2325c6338 100644 --- a/app/user.go +++ b/app/user.go @@ -162,7 +162,7 @@ func (a *App) CreateUserFromSignup(user *model.User) (*model.User, *model.AppErr } func (a *App) IsUserSignUpAllowed() *model.AppError { - if !a.Config().EmailSettings.EnableSignUpWithEmail || !a.Config().TeamSettings.EnableUserCreation { + if !a.Config().EmailSettings.EnableSignUpWithEmail || !*a.Config().TeamSettings.EnableUserCreation { err := model.NewAppError("IsUserSignUpAllowed", "api.user.create_user.signup_email_disabled.app_error", nil, "", http.StatusNotImplemented) return err } @@ -250,7 +250,7 @@ func (a *App) createUser(user *model.User) (*model.User, *model.AppError) { } func (a *App) CreateOAuthUser(service string, userData io.Reader, teamId string) (*model.User, *model.AppError) { - if !a.Config().TeamSettings.EnableUserCreation { + if !*a.Config().TeamSettings.EnableUserCreation { return nil, model.NewAppError("CreateOAuthUser", "api.user.create_user.disabled.app_error", nil, "", http.StatusNotImplemented) } diff --git a/app/user_test.go b/app/user_test.go index 20dafd826..f0e026fa9 100644 --- a/app/user_test.go +++ b/app/user_test.go @@ -88,7 +88,7 @@ func TestCreateOAuthUser(t *testing.T) { th.App.PermanentDeleteUser(user) - th.App.Config().TeamSettings.EnableUserCreation = false + *th.App.Config().TeamSettings.EnableUserCreation = false _, err = th.App.CreateOAuthUser(model.USER_AUTH_SERVICE_GITLAB, strings.NewReader(json), th.BasicTeam.Id) if err == nil { diff --git a/model/config.go b/model/config.go index 64107c42d..a54d44110 100644 --- a/model/config.go +++ b/model/config.go @@ -980,7 +980,7 @@ type TeamSettings struct { SiteName string MaxUsersPerTeam *int EnableTeamCreation *bool - EnableUserCreation bool + EnableUserCreation *bool EnableOpenServer *bool RestrictCreationToDomains string EnableCustomBrand *bool @@ -1111,6 +1111,11 @@ func (s *TeamSettings) SetDefaults() { if s.EnableTeamCreation == nil { s.EnableTeamCreation = NewBool(true) } + + if s.EnableUserCreation == nil { + s.EnableUserCreation = NewBool(true) + } + } type ClientRequirements struct { diff --git a/utils/config.go b/utils/config.go index 1a68b80d7..c3f58cc79 100644 --- a/utils/config.go +++ b/utils/config.go @@ -448,7 +448,7 @@ func GenerateClientConfig(c *model.Config, diagnosticId string, license *model.L props["WebsocketURL"] = strings.TrimRight(*c.ServiceSettings.WebsocketURL, "/") props["SiteName"] = c.TeamSettings.SiteName props["EnableTeamCreation"] = strconv.FormatBool(*c.TeamSettings.EnableTeamCreation) - props["EnableUserCreation"] = strconv.FormatBool(c.TeamSettings.EnableUserCreation) + props["EnableUserCreation"] = strconv.FormatBool(*c.TeamSettings.EnableUserCreation) props["EnableOpenServer"] = strconv.FormatBool(*c.TeamSettings.EnableOpenServer) props["RestrictDirectMessage"] = *c.TeamSettings.RestrictDirectMessage props["RestrictTeamInvite"] = *c.TeamSettings.RestrictTeamInvite |