diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-10-21 11:31:31 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-10-21 11:31:31 -0400 |
commit | 0e49acede9b077a1533d9a55494277fbc952d47c (patch) | |
tree | 4991c8823458d57b127eff3106466188b6403675 /model | |
parent | a4e6cce98eb0c04deaa929ccd28b266e312c0ca1 (diff) | |
parent | 0bfdfd79f0071cfd41f2dfbe20d1cb099b57a15c (diff) | |
download | chat-0e49acede9b077a1533d9a55494277fbc952d47c.tar.gz chat-0e49acede9b077a1533d9a55494277fbc952d47c.tar.bz2 chat-0e49acede9b077a1533d9a55494277fbc952d47c.zip |
Merge pull request #1131 from mattermost/PLT-350
PLT-350 allow ability to disable restricted team names
Diffstat (limited to 'model')
-rw-r--r-- | model/config.go | 6 | ||||
-rw-r--r-- | model/team.go | 4 | ||||
-rw-r--r-- | model/team_test.go | 16 |
3 files changed, 16 insertions, 10 deletions
diff --git a/model/config.go b/model/config.go index 3a39df2f1..216b1de86 100644 --- a/model/config.go +++ b/model/config.go @@ -122,6 +122,7 @@ type TeamSettings struct { EnableTeamCreation bool EnableUserCreation bool RestrictCreationToDomains string + RestrictTeamNames *bool } type Config struct { @@ -169,6 +170,11 @@ func (o *Config) SetDefaults() { o.ServiceSettings.EnableSecurityFixAlert = new(bool) *o.ServiceSettings.EnableSecurityFixAlert = true } + + if o.TeamSettings.RestrictTeamNames == nil { + o.TeamSettings.RestrictTeamNames = new(bool) + *o.TeamSettings.RestrictTeamNames = true + } } func (o *Config) IsValid() *AppError { diff --git a/model/team.go b/model/team.go index 584c78f8d..9da2cd5b2 100644 --- a/model/team.go +++ b/model/team.go @@ -97,7 +97,7 @@ func (o *Team) Etag() string { return Etag(o.Id, o.UpdateAt) } -func (o *Team) IsValid() *AppError { +func (o *Team) IsValid(restrictTeamNames bool) *AppError { if len(o.Id) != 26 { return NewAppError("Team.IsValid", "Invalid Id", "") @@ -127,7 +127,7 @@ func (o *Team) IsValid() *AppError { return NewAppError("Team.IsValid", "Invalid URL Identifier", "id="+o.Id) } - if IsReservedTeamName(o.Name) { + if restrictTeamNames && IsReservedTeamName(o.Name) { return NewAppError("Team.IsValid", "This URL is unavailable. Please try another.", "id="+o.Id) } diff --git a/model/team_test.go b/model/team_test.go index fd2428f03..112d48a9d 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(); err == nil { + if err := o.IsValid(true); err == nil { t.Fatal("should be invalid") } o.Id = NewId() - if err := o.IsValid(); err == nil { + if err := o.IsValid(true); err == nil { t.Fatal("should be invalid") } o.CreateAt = GetMillis() - if err := o.IsValid(); err == nil { + if err := o.IsValid(true); err == nil { t.Fatal("should be invalid") } o.UpdateAt = GetMillis() - if err := o.IsValid(); err == nil { + if err := o.IsValid(true); err == nil { t.Fatal("should be invalid") } o.Email = strings.Repeat("01234567890", 20) - if err := o.IsValid(); err == nil { + if err := o.IsValid(true); err == nil { t.Fatal("should be invalid") } o.Email = "corey@hulen.com" o.DisplayName = strings.Repeat("01234567890", 20) - if err := o.IsValid(); err == nil { + if err := o.IsValid(true); err == nil { t.Fatal("should be invalid") } o.DisplayName = "1234" o.Name = "ZZZZZZZ" - if err := o.IsValid(); err == nil { + if err := o.IsValid(true); err == nil { t.Fatal("should be invalid") } o.Name = "zzzzz" o.Type = TEAM_OPEN - if err := o.IsValid(); err != nil { + if err := o.IsValid(true); err != nil { t.Fatal(err) } } |