mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Viewers with viewers_can_edit should be able to access /explore (#15787)
* fix: Viewers with viewers_can_edit should be able to access /explore #15773 * refactoring initial PR a bit to simplify function and reduce duplication
This commit is contained in:
committed by
Torkel Ödegaard
parent
be8f60b0bf
commit
a81d5486b0
@@ -4,7 +4,7 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/macaron.v1"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
@@ -52,6 +52,12 @@ func notAuthorized(c *m.ReqContext) {
|
||||
c.Redirect(setting.AppSubUrl + "/login")
|
||||
}
|
||||
|
||||
func EnsureEditorOrViewerCanEdit(c *m.ReqContext) {
|
||||
if !c.SignedInUser.HasRole(m.ROLE_EDITOR) && !setting.ViewersCanEdit {
|
||||
accessForbidden(c)
|
||||
}
|
||||
}
|
||||
|
||||
func RoleAuth(roles ...m.RoleType) macaron.Handler {
|
||||
return func(c *m.ReqContext) {
|
||||
ok := false
|
||||
|
Reference in New Issue
Block a user