lib/roleman/authenticator.rb
# Authorize user has role for request path and method
# @param [User,Hash] user User Model
# @param [path] Request path
# @param [ActionDispatch::Request] Request Object
# @param [Hash] extras Extra values for authorize
Authorize user has role for request path and method
Authorize user has role for request path and method
def authorize(user, path: nil, request: nil, method: 'GET', extras: {})
      path = get_path(path: path, request: request)
      route = @router.find_route(path, method)
      unless route
        if @config.raise_unknown_path
          @config.raise_unknown_path.call(user, request)
          return
        else
          return true
        end
      end
      role = get_role(user, @config.role_field)
      if route.enabled_roles.include?(role)
        return true
      else
        return false
      end
    end
def authorize ( user , path : nil , request : nil , method : 'GET' , extras : { } ) path = get_path ( path : path , request : request ) route = @router . find_route ( path , method ) unless route if @config . raise_unknown_path @config . raise_unknown_path . call ( user , request ) return else return true end end role = get_role ( user , @config . role_field ) if route . enabled_roles . include? ( role ) return true else return false end end
Authorize user has role for request path and method
Authorize user has role for request path and method
user
path
request
method
extras
extras Extra values for authorize
extras Extra values for authorize