Handle request service account when not enabled (#42122)

* Handle request service account when not enabled
This commit is contained in:
Jeremy Price 2021-11-24 11:56:55 +01:00 committed by GitHub
parent fe84454bb0
commit a145ec37bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,6 +96,10 @@ func (hs *HTTPServer) AddAPIKey(c *models.ReqContext, cmd models.AddApiKeyComman
return response.Error(403, "Target service is not in the same organisation as requesting user or api key", err)
}
}
} else {
if cmd.CreateNewServiceAccount {
return response.Error(400, "Service accounts disabled. Retry create api request without service account flag.", err)
}
}
newKeyInfo, err := apikeygen.New(cmd.OrgId, cmd.Name)