-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds checking of reserved keywords against team names #22
Changes from all commits
5a12d6e
6ebf426
12a61da
e929af2
6662e9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,13 +194,29 @@ func (t *Team) RemoveRepository(repoID int64) error { | |
return sess.Commit() | ||
} | ||
|
||
func IsUsableTeamName(name string) (err error) { | ||
var reservedTeamNames = []string{"new"} | ||
|
||
for i := range reservedTeamNames { | ||
if name == reservedTeamNames[i] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. case sensitive? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did it in the same manner as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Macaron isn't (apparently) case insensitive ( test by going to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lunny is right, you should always downcase the name. |
||
return ErrNameReserved{name} | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// NewTeam creates a record of new team. | ||
// It's caller's responsibility to assign organization ID. | ||
func NewTeam(t *Team) error { | ||
func NewTeam(t *Team) (err error) { | ||
if len(t.Name) == 0 { | ||
return errors.New("empty team name") | ||
} | ||
|
||
if err = IsUsableTeamName(t.Name); err != nil { | ||
return err | ||
} | ||
|
||
has, err := x.Id(t.OrgID).Get(new(User)) | ||
if err != nil { | ||
return err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.