mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Change API to expect UIDs instead of ID * Remove unnecessary transactions When only one query is executed * Modify API responses * Cleanup tests * Use globally orgID and UID for identifying alert definitions
21 lines
521 B
Go
21 lines
521 B
Go
package ngalert
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
func (ng *AlertNG) validateOrgAlertDefinition(c *models.ReqContext) {
|
|
uid := c.ParamsEscape(":alertDefinitionUID")
|
|
query := getAlertDefinitionByUIDQuery{UID: uid, OrgID: c.SignedInUser.OrgId}
|
|
|
|
if err := ng.getAlertDefinitionByUID(&query); err != nil {
|
|
c.JsonApiErr(404, "Alert definition not found", nil)
|
|
return
|
|
}
|
|
|
|
if c.OrgId != query.Result.OrgID {
|
|
c.JsonApiErr(403, "You are not allowed to edit/view alert definition", nil)
|
|
return
|
|
}
|
|
}
|