mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
API: Add theme validation (#38432)
* Add theme validation * Fix lint for const
This commit is contained in:
parent
403bbd0144
commit
ccab9611cb
@ -7,6 +7,12 @@ import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultTheme string = ""
|
||||
darkTheme string = "dark"
|
||||
lightTheme string = "light"
|
||||
)
|
||||
|
||||
// POST /api/preferences/set-home-dash
|
||||
func SetHomeDashboard(c *models.ReqContext, cmd models.SavePreferencesCommand) response.Response {
|
||||
cmd.UserId = c.UserId
|
||||
@ -46,6 +52,9 @@ func UpdateUserPreferences(c *models.ReqContext, dtoCmd dtos.UpdatePrefsCmd) res
|
||||
}
|
||||
|
||||
func updatePreferencesFor(orgID, userID, teamId int64, dtoCmd *dtos.UpdatePrefsCmd) response.Response {
|
||||
if dtoCmd.Theme != lightTheme && dtoCmd.Theme != darkTheme && dtoCmd.Theme != defaultTheme {
|
||||
return response.Error(400, "Invalid theme", nil)
|
||||
}
|
||||
saveCmd := models.SavePreferencesCommand{
|
||||
UserId: userID,
|
||||
OrgId: orgID,
|
||||
|
Loading…
Reference in New Issue
Block a user