diff --git a/grafana b/grafana index 64f98d24091..a0036179d50 160000 --- a/grafana +++ b/grafana @@ -1 +1 @@ -Subproject commit 64f98d2409152a2bfa34b6f032d21e6bb18b97f8 +Subproject commit a0036179d500366e28552d2c332fd50f534913a3 diff --git a/pkg/api/account.go b/pkg/api/account.go index d4ed3a6c2e1..94dfa693465 100644 --- a/pkg/api/account.go +++ b/pkg/api/account.go @@ -18,14 +18,7 @@ func GetAccount(c *middleware.Context) { c.JSON(200, query.Result) } -func UpdateAccount(c *middleware.Context) { - cmd := m.UpdateAccountCommand{} - - if !c.JsonBody(&cmd) { - c.JsonApiErr(400, "Invalid request", nil) - return - } - +func UpdateAccount(c *middleware.Context, cmd m.UpdateAccountCommand) { cmd.AccountId = c.AccountId if err := bus.Dispatch(&cmd); err != nil { diff --git a/pkg/api/api.go b/pkg/api/api.go index 0593231d6ab..aab4e54e329 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -40,7 +40,7 @@ func Register(r *macaron.Macaron) { // account r.Group("/account", func() { r.Get("/", GetAccount) - r.Post("/", UpdateAccount) + r.Post("/", bind(m.UpdateAccountCommand{}), UpdateAccount) r.Put("/collaborators", bind(m.AddCollaboratorCommand{}), AddCollaborator) r.Get("/collaborators", GetCollaborators) r.Delete("/collaborators/:id", RemoveCollaborator) diff --git a/pkg/middleware/middleware.go b/pkg/middleware/middleware.go index 431883e69a0..9fb3f984b7c 100644 --- a/pkg/middleware/middleware.go +++ b/pkg/middleware/middleware.go @@ -58,6 +58,7 @@ func GetContextHandler() macaron.Handler { // api key role ctx.UserRole = tokenInfo.Role + ctx.ApiKeyId = tokenInfo.Id ctx.UsingAccountId = ctx.AccountId ctx.UsingAccountName = ctx.UserName } diff --git a/pkg/models/account.go b/pkg/models/account.go index 5aaf0d38639..36277a4b9c9 100644 --- a/pkg/models/account.go +++ b/pkg/models/account.go @@ -42,7 +42,7 @@ type CreateAccountCommand struct { } type UpdateAccountCommand struct { - Email string `json:"email" binding:"required"` + Email string `json:"email" binding:"Required"` Login string `json:"login"` Name string `json:"name"` @@ -100,6 +100,7 @@ type SignedInUser struct { UserLogin string UserName string UserEmail string + ApiKeyId int64 IsGrafanaAdmin bool }