Forbid creation of dashboard permissions with both a user and a team (#40104)

These permissions could be created through the API but would not show
correctly in the UI.
This commit is contained in:
Jesse Weaver
2021-10-13 12:16:58 -06:00
committed by GitHub
parent 3fb8b87972
commit 5af96544f3
3 changed files with 51 additions and 5 deletions
+4
View File
@@ -112,6 +112,10 @@ func (hs *HTTPServer) UpdateDashboardPermissions(c *models.ReqContext, apiCmd dt
func validatePermissionsUpdate(apiCmd dtos.UpdateDashboardAclCommand) error {
for _, item := range apiCmd.Items {
if item.UserID > 0 && item.TeamID > 0 {
return models.ErrPermissionsWithUserAndTeamNotAllowed
}
if (item.UserID > 0 || item.TeamID > 0) && item.Role != nil {
return models.ErrPermissionsWithRoleNotAllowed
}