Explorar el Código

dashfolders: check permissions for new dashboard

ref #10275. Use the parent folder permissions if new dashboard and
it does not have an id yet.
Daniel Lee hace 8 años
padre
commit
c27a74bb6b
Se han modificado 1 ficheros con 8 adiciones y 1 borrados
  1. 8 1
      pkg/api/dashboard.go

+ 8 - 1
pkg/api/dashboard.go

@@ -158,7 +158,14 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
 
 	dash := cmd.GetDashboardModel()
 
-	guardian := guardian.NewDashboardGuardian(dash.Id, c.OrgId, c.SignedInUser)
+	dashId := dash.Id
+
+	// if new dashboard, use parent folder permissions instead
+	if dashId == 0 {
+		dashId = cmd.FolderId
+	}
+
+	guardian := guardian.NewDashboardGuardian(dashId, c.OrgId, c.SignedInUser)
 	if canSave, err := guardian.CanSave(); err != nil || !canSave {
 		return dashboardGuardianResponse(err)
 	}