teams: cleanup.

This commit is contained in:
Leonard Gram
2019-03-11 11:26:01 +01:00
parent 3be1d71f1f
commit 0d61f89577
3 changed files with 18 additions and 15 deletions

View File

@ -41,7 +41,12 @@ func (hs *HTTPServer) CreateTeam(c *m.ReqContext, cmd m.CreateTeamCommand) Respo
func UpdateTeam(c *m.ReqContext, cmd m.UpdateTeamCommand) Response {
cmd.OrgId = c.OrgId
cmd.Id = c.ParamsInt64(":teamId")
if err := teams.UpdateTeam(c.SignedInUser, &cmd); err != nil {
if err := teams.CanUpdateTeam(cmd.OrgId, cmd.Id, c.SignedInUser); err != nil {
return Error(403, "User not allowed to update team", err)
}
if err := bus.Dispatch(&cmd); err != nil {
if err == m.ErrTeamNameTaken {
return Error(400, "Team name taken", err)
}