teams: editor added as admin for created teams.

This commit is contained in:
Leonard Gram
2019-03-19 13:57:22 +01:00
parent 22e098b830
commit af4994ba16
5 changed files with 37 additions and 17 deletions
+12 -1
View File
@@ -8,7 +8,7 @@ import (
)
// POST /api/teams
func CreateTeam(c *m.ReqContext, cmd m.CreateTeamCommand) Response {
func (hs *HTTPServer) CreateTeam(c *m.ReqContext, cmd m.CreateTeamCommand) Response {
cmd.OrgId = c.OrgId
if err := bus.Dispatch(&cmd); err != nil {
if err == m.ErrTeamNameTaken {
@@ -17,6 +17,17 @@ func CreateTeam(c *m.ReqContext, cmd m.CreateTeamCommand) Response {
return Error(500, "Failed to create Team", err)
}
if c.OrgRole == m.ROLE_EDITOR && hs.Cfg.EditorsCanOwn {
addMemberCmd := m.AddTeamMemberCommand{
UserId: c.SignedInUser.UserId,
OrgId: cmd.OrgId,
TeamId: cmd.Result.Id,
Permission: int64(m.PERMISSION_ADMIN),
}
err := bus.Dispatch(&addMemberCmd)
c.Logger.Error("Could not add creator to team.", "error", err)
}
return JSON(200, &util.DynMap{
"teamId": cmd.Result.Id,
"message": "Team created",