diff options
author | LefsFlare <LefsFlarey@users.noreply.github.com> | 2016-11-06 17:07:03 +0800 |
---|---|---|
committer | Sandro Santilli <strk@kbt.io> | 2016-11-06 10:07:03 +0100 |
commit | 55a4d46f5d2aa114752ac3880d0d75ed288fea67 (patch) | |
tree | 541dfdc126892563a6ab7883201989a30c09403c /models/org_team.go | |
parent | fe8bfa54dea3c4d513e64c86bd4ec555d2ca27be (diff) | |
download | gitea-55a4d46f5d2aa114752ac3880d0d75ed288fea67.tar.gz gitea-55a4d46f5d2aa114752ac3880d0d75ed288fea67.zip |
Adds checking of reserved keywords against team names (#22)
Diffstat (limited to 'models/org_team.go')
-rw-r--r-- | models/org_team.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/models/org_team.go b/models/org_team.go index 6a6754cc99..07a90e08f1 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -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] { + 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 |