diff options
-rw-r--r-- | api/team.go | 2 | ||||
-rw-r--r-- | config/config.json | 1 | ||||
-rw-r--r-- | model/config.go | 6 | ||||
-rw-r--r-- | model/team.go | 4 | ||||
-rw-r--r-- | model/team_test.go | 27 | ||||
-rw-r--r-- | model/utils.go | 47 | ||||
-rw-r--r-- | store/sql_team_store.go | 4 | ||||
-rw-r--r-- | utils/config.go | 1 | ||||
-rw-r--r-- | utils/diagnostic.go | 1 | ||||
-rw-r--r-- | webapp/components/admin_console/users_and_teams_settings.jsx | 19 | ||||
-rw-r--r-- | webapp/components/create_team/components/team_url.jsx | 10 | ||||
-rw-r--r-- | webapp/utils/constants.jsx | 18 |
12 files changed, 27 insertions, 113 deletions
diff --git a/api/team.go b/api/team.go index c57591d46..4d4795ab6 100644 --- a/api/team.go +++ b/api/team.go @@ -122,7 +122,7 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) { teamSignup.Team.PreSave() - if err := teamSignup.Team.IsValid(*utils.Cfg.TeamSettings.RestrictTeamNames); err != nil { + if err := teamSignup.Team.IsValid(); err != nil { c.Err = err return } diff --git a/config/config.json b/config/config.json index 02e300897..0a154446e 100644 --- a/config/config.json +++ b/config/config.json @@ -43,7 +43,6 @@ "EnableUserCreation": true, "EnableOpenServer": false, "RestrictCreationToDomains": "", - "RestrictTeamNames": true, "EnableCustomBrand": false, "CustomBrandText": "", "CustomDescriptionText": "", diff --git a/model/config.go b/model/config.go index 09bf11a71..321307539 100644 --- a/model/config.go +++ b/model/config.go @@ -214,7 +214,6 @@ type TeamSettings struct { EnableUserCreation bool EnableOpenServer *bool RestrictCreationToDomains string - RestrictTeamNames *bool EnableCustomBrand *bool CustomBrandText *string CustomDescriptionText *string @@ -453,11 +452,6 @@ func (o *Config) SetDefaults() { *o.PasswordSettings.Symbol = false } - if o.TeamSettings.RestrictTeamNames == nil { - o.TeamSettings.RestrictTeamNames = new(bool) - *o.TeamSettings.RestrictTeamNames = true - } - if o.TeamSettings.EnableCustomBrand == nil { o.TeamSettings.EnableCustomBrand = new(bool) *o.TeamSettings.EnableCustomBrand = false diff --git a/model/team.go b/model/team.go index dccc0219e..38feda325 100644 --- a/model/team.go +++ b/model/team.go @@ -100,7 +100,7 @@ func (o *Team) Etag() string { return Etag(o.Id, o.UpdateAt) } -func (o *Team) IsValid(restrictTeamNames bool) *AppError { +func (o *Team) IsValid() *AppError { if len(o.Id) != 26 { return NewLocAppError("Team.IsValid", "model.team.is_valid.id.app_error", nil, "") @@ -130,7 +130,7 @@ func (o *Team) IsValid(restrictTeamNames bool) *AppError { return NewLocAppError("Team.IsValid", "model.team.is_valid.url.app_error", nil, "id="+o.Id) } - if restrictTeamNames && IsReservedTeamName(o.Name) { + if IsReservedTeamName(o.Name) { return NewLocAppError("Team.IsValid", "model.team.is_valid.reserved.app_error", nil, "id="+o.Id) } diff --git a/model/team_test.go b/model/team_test.go index 4b691e76a..eb7e27b0e 100644 --- a/model/team_test.go +++ b/model/team_test.go @@ -21,45 +21,45 @@ func TestTeamJson(t *testing.T) { func TestTeamIsValid(t *testing.T) { o := Team{} - if err := o.IsValid(true); err == nil { + if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } o.Id = NewId() - if err := o.IsValid(true); err == nil { + if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } o.CreateAt = GetMillis() - if err := o.IsValid(true); err == nil { + if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } o.UpdateAt = GetMillis() - if err := o.IsValid(true); err == nil { + if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } o.Email = strings.Repeat("01234567890", 20) - if err := o.IsValid(true); err == nil { + if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } o.Email = "corey+test@hulen.com" o.DisplayName = strings.Repeat("01234567890", 20) - if err := o.IsValid(true); err == nil { + if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } o.DisplayName = "1234" o.Name = "ZZZZZZZ" - if err := o.IsValid(true); err == nil { + if err := o.IsValid(); err == nil { t.Fatal("should be invalid") } o.Name = "zzzzz" o.Type = TEAM_OPEN - if err := o.IsValid(true); err != nil { + if err := o.IsValid(); err != nil { t.Fatal(err) } } @@ -104,8 +104,6 @@ var tReservedDomains = []struct { value string expected bool }{ - {"test-hello", true}, - {"test", true}, {"admin", true}, {"Admin-punch", true}, {"spin-punch-admin", false}, @@ -120,15 +118,14 @@ func TestReservedTeamName(t *testing.T) { } func TestCleanTeamName(t *testing.T) { - if CleanTeamName("Jimbo's Team") != "jimbos-team" { - t.Fatal("didn't clean name properly") - } - if len(CleanTeamName("Test")) != 26 { + if CleanTeamName("Jimbo's Admin") != "jimbos-admin" { t.Fatal("didn't clean name properly") } - if CleanTeamName("Team Really cool") != "really-cool" { + + if CleanTeamName("Admin Really cool") != "really-cool" { t.Fatal("didn't clean name properly") } + if CleanTeamName("super-duper-guys") != "super-duper-guys" { t.Fatal("didn't clean name properly") } diff --git a/model/utils.go b/model/utils.go index 4ebd23939..457b64c09 100644 --- a/model/utils.go +++ b/model/utils.go @@ -253,58 +253,15 @@ func IsValidEmail(email string) bool { } var reservedName = []string{ - "www", - "web", + "signup", + "login", "admin", - "support", - "notify", - "test", - "demo", - "mail", - "team", "channel", - "internal", - "localhost", - "dockerhost", - "stag", "post", - "cluster", "api", "oauth", } -var wwwStart = regexp.MustCompile(`^www`) -var betaStart = regexp.MustCompile(`^beta`) -var ciStart = regexp.MustCompile(`^ci`) - -func GetSubDomain(s string) (string, string) { - s = strings.Replace(s, "http://", "", 1) - s = strings.Replace(s, "https://", "", 1) - - match := wwwStart.MatchString(s) - if match { - return "", "" - } - - match = betaStart.MatchString(s) - if match { - return "", "" - } - - match = ciStart.MatchString(s) - if match { - return "", "" - } - - parts := strings.Split(s, ".") - - if len(parts) != 3 { - return "", "" - } - - return parts[0], parts[1] -} - func IsValidChannelIdentifier(s string) bool { if !IsValidAlphaNum(s, true) { diff --git a/store/sql_team_store.go b/store/sql_team_store.go index a69c84904..7addb980e 100644 --- a/store/sql_team_store.go +++ b/store/sql_team_store.go @@ -65,7 +65,7 @@ func (s SqlTeamStore) Save(team *model.Team) StoreChannel { team.PreSave() - if result.Err = team.IsValid(*utils.Cfg.TeamSettings.RestrictTeamNames); result.Err != nil { + if result.Err = team.IsValid(); result.Err != nil { storeChannel <- result close(storeChannel) return @@ -97,7 +97,7 @@ func (s SqlTeamStore) Update(team *model.Team) StoreChannel { team.PreUpdate() - if result.Err = team.IsValid(*utils.Cfg.TeamSettings.RestrictTeamNames); result.Err != nil { + if result.Err = team.IsValid(); result.Err != nil { storeChannel <- result close(storeChannel) return diff --git a/utils/config.go b/utils/config.go index c67de906e..819ce6185 100644 --- a/utils/config.go +++ b/utils/config.go @@ -236,7 +236,6 @@ func getClientConfig(c *model.Config) map[string]string { props["EnableTeamCreation"] = strconv.FormatBool(c.TeamSettings.EnableTeamCreation) props["EnableUserCreation"] = strconv.FormatBool(c.TeamSettings.EnableUserCreation) props["EnableOpenServer"] = strconv.FormatBool(*c.TeamSettings.EnableOpenServer) - props["RestrictTeamNames"] = strconv.FormatBool(*c.TeamSettings.RestrictTeamNames) props["RestrictDirectMessage"] = *c.TeamSettings.RestrictDirectMessage props["RestrictTeamInvite"] = *c.TeamSettings.RestrictTeamInvite props["RestrictPublicChannelManagement"] = *c.TeamSettings.RestrictPublicChannelManagement diff --git a/utils/diagnostic.go b/utils/diagnostic.go index 88a409869..7509ccbb5 100644 --- a/utils/diagnostic.go +++ b/utils/diagnostic.go @@ -87,7 +87,6 @@ func trackConfig() { SendDiagnostic(TRACK_CONFIG_TEAM, map[string]interface{}{ "enable_user_creation": Cfg.TeamSettings.EnableUserCreation, "enable_team_creation": Cfg.TeamSettings.EnableTeamCreation, - "restrict_team_names": *Cfg.TeamSettings.RestrictTeamNames, "restrict_team_invite": *Cfg.TeamSettings.RestrictTeamInvite, "restrict_public_channel_management": *Cfg.TeamSettings.RestrictPublicChannelManagement, "restrict_private_channel_management": *Cfg.TeamSettings.RestrictPrivateChannelManagement, diff --git a/webapp/components/admin_console/users_and_teams_settings.jsx b/webapp/components/admin_console/users_and_teams_settings.jsx index 60ee70264..dd19005c8 100644 --- a/webapp/components/admin_console/users_and_teams_settings.jsx +++ b/webapp/components/admin_console/users_and_teams_settings.jsx @@ -30,7 +30,6 @@ export default class UsersAndTeamsSettings extends AdminSettings { config.TeamSettings.EnableTeamCreation = this.state.enableTeamCreation; config.TeamSettings.MaxUsersPerTeam = this.parseIntNonZero(this.state.maxUsersPerTeam, Constants.DEFAULT_MAX_USERS_PER_TEAM); config.TeamSettings.RestrictCreationToDomains = this.state.restrictCreationToDomains; - config.TeamSettings.RestrictTeamNames = this.state.restrictTeamNames; config.TeamSettings.RestrictDirectMessage = this.state.restrictDirectMessage; config.TeamSettings.MaxChannelsPerTeam = this.parseIntNonZero(this.state.maxChannelsPerTeam, Constants.DEFAULT_MAX_CHANNELS_PER_TEAM); @@ -43,7 +42,6 @@ export default class UsersAndTeamsSettings extends AdminSettings { enableTeamCreation: config.TeamSettings.EnableTeamCreation, maxUsersPerTeam: config.TeamSettings.MaxUsersPerTeam, restrictCreationToDomains: config.TeamSettings.RestrictCreationToDomains, - restrictTeamNames: config.TeamSettings.RestrictTeamNames, restrictDirectMessage: config.TeamSettings.RestrictDirectMessage, maxChannelsPerTeam: config.TeamSettings.MaxChannelsPerTeam }; @@ -151,23 +149,6 @@ export default class UsersAndTeamsSettings extends AdminSettings { value={this.state.restrictCreationToDomains} onChange={this.handleChange} /> - <BooleanSetting - id='restrictTeamNames' - label={ - <FormattedMessage - id='admin.team.restrictNameTitle' - defaultMessage='Restrict Team Names: ' - /> - } - helpText={ - <FormattedMessage - id='admin.team.restrictNameDesc' - defaultMessage='When true, You cannot create a team name with reserved words like www, admin, support, test, channel, etc' - /> - } - value={this.state.restrictTeamNames} - onChange={this.handleChange} - /> <DropdownSetting id='restrictDirectMessage' values={[ diff --git a/webapp/components/create_team/components/team_url.jsx b/webapp/components/create_team/components/team_url.jsx index d2ccc97d9..b943f983c 100644 --- a/webapp/components/create_team/components/team_url.jsx +++ b/webapp/components/create_team/components/team_url.jsx @@ -54,12 +54,10 @@ export default class TeamUrl extends React.Component { return; } - if (global.window.mm_config.RestrictTeamNames === 'true') { - for (let index = 0; index < Constants.RESERVED_TEAM_NAMES.length; index++) { - if (cleanedName.indexOf(Constants.RESERVED_TEAM_NAMES[index]) === 0) { - this.setState({nameError: Utils.localizeMessage('create_team.team_url.taken', 'URL is taken or contains a reserved word')}); - return; - } + for (let index = 0; index < Constants.RESERVED_TEAM_NAMES.length; index++) { + if (cleanedName.indexOf(Constants.RESERVED_TEAM_NAMES[index]) === 0) { + this.setState({nameError: Utils.localizeMessage('create_team.team_url.taken', 'URL is taken or contains a reserved word')}); + return; } } diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index efc0d8482..663a8863c 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -331,23 +331,13 @@ export const Constants = { SYSTEM_MESSAGE_PROFILE_NAME: 'System', SYSTEM_MESSAGE_PROFILE_IMAGE: logoImage, RESERVED_TEAM_NAMES: [ - 'www', - 'web', + 'signup', + 'login', 'admin', - 'support', - 'notify', - 'test', - 'demo', - 'mail', - 'team', 'channel', - 'internal', - 'localhost', - 'dockerhost', - 'stag', 'post', - 'cluster', - 'api' + 'api', + 'oauth' ], RESERVED_USERNAMES: [ 'valet', |