Fix CreateTeam api endpoint

No team member should be created for requests
authenticated by API tokens.
pull/18252/head
Sofia Papagiannaki 6 years ago
parent 3145a1dd29
commit 9fcc4e67f5
  1. 2
      pkg/api/team.go
  2. 2
      pkg/middleware/middleware.go

@ -23,7 +23,7 @@ func (hs *HTTPServer) CreateTeam(c *m.ReqContext, cmd m.CreateTeamCommand) Respo
return Error(500, "Failed to create Team", err)
}
if c.OrgRole == m.ROLE_EDITOR && hs.Cfg.EditorsCanAdmin {
if c.OrgRole == m.ROLE_EDITOR && hs.Cfg.EditorsCanAdmin && !c.SignedInUser.IsAnonymous {
addMemberCmd := m.AddTeamMemberCommand{
UserId: c.SignedInUser.UserId,
OrgId: cmd.OrgId,

@ -132,7 +132,7 @@ func initContextWithApiKey(ctx *models.ReqContext) bool {
}
ctx.IsSignedIn = true
ctx.SignedInUser = &models.SignedInUser{}
ctx.SignedInUser = &models.SignedInUser{IsAnonymous: true}
ctx.OrgRole = apikey.Role
ctx.ApiKeyId = apikey.Id
ctx.OrgId = apikey.OrgId

Loading…
Cancel
Save