mirror of
				https://github.com/grafana/grafana.git
				synced 2025-02-25 18:55:37 -06:00 
			
		
		
		
	Role checking when saving dashboard, making sure that the user has owner or editor role
This commit is contained in:
		@@ -60,6 +60,21 @@ func authDenied(c *Context) {
 | 
			
		||||
	c.Redirect(setting.AppSubUrl + "/login")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func RoleAuth(roles ...m.RoleType) macaron.Handler {
 | 
			
		||||
	return func(c *Context) {
 | 
			
		||||
		ok := false
 | 
			
		||||
		for _, role := range roles {
 | 
			
		||||
			if role == c.UserRole {
 | 
			
		||||
				ok = true
 | 
			
		||||
				break
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if !ok {
 | 
			
		||||
			authDenied(c)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Auth(options *AuthOptions) macaron.Handler {
 | 
			
		||||
	return func(c *Context) {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user