mirror of
https://github.com/grafana/grafana.git
synced 2026-08-18 17:15:08 -05:00
Access Control: Fix permission error during dashboard creation flow (#53214)
* remove permission check * remove unneeded function
This commit is contained in:
@@ -648,10 +648,6 @@ func (l *LibraryElementService) getElementsForDashboardID(c context.Context, das
|
|||||||
|
|
||||||
// connectElementsToDashboardID adds connections for all elements Library Elements in a Dashboard.
|
// connectElementsToDashboardID adds connections for all elements Library Elements in a Dashboard.
|
||||||
func (l *LibraryElementService) connectElementsToDashboardID(c context.Context, signedInUser *models.SignedInUser, elementUIDs []string, dashboardID int64) error {
|
func (l *LibraryElementService) connectElementsToDashboardID(c context.Context, signedInUser *models.SignedInUser, elementUIDs []string, dashboardID int64) error {
|
||||||
if err := l.requireEditPermissionsOnDashboard(c, signedInUser, dashboardID); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err := l.SQLStore.WithTransactionalDbSession(c, func(session *sqlstore.DBSession) error {
|
err := l.SQLStore.WithTransactionalDbSession(c, func(session *sqlstore.DBSession) error {
|
||||||
_, err := session.Exec("DELETE FROM "+models.LibraryElementConnectionTableName+" WHERE kind=1 AND connection_id=?", dashboardID)
|
_, err := session.Exec("DELETE FROM "+models.LibraryElementConnectionTableName+" WHERE kind=1 AND connection_id=?", dashboardID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -72,17 +72,3 @@ func (l *LibraryElementService) requireViewPermissionsOnFolder(ctx context.Conte
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LibraryElementService) requireEditPermissionsOnDashboard(ctx context.Context, user *models.SignedInUser, dashboardID int64) error {
|
|
||||||
g := guardian.New(ctx, dashboardID, user.OrgId, user)
|
|
||||||
|
|
||||||
canEdit, err := g.CanEdit()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !canEdit {
|
|
||||||
return dashboards.ErrDashboardUpdateAccessDenied
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user