-
Notifications
You must be signed in to change notification settings - Fork 0
Requires Policies Filter
Nessa edited this page Dec 18, 2016
·
1 revision
- Requires Permission Filter
def has_permission?( permission_name )
# controller helper
if property && authorized_application
application_has_permission?( permission_name )
elsif params[ :access_token ]
permitted = false
if policies.present?
policies.each do |policy|
permitted = true if policy.actions.include?( permission_name.split(".").last )
end
end
permitted
else
false
end
end
- Requires Policies Filter
if access_token.present?
policies = controller.retrieve_policies( @resource_name, access_token, realm_uuid )
if policies.present? && policies.is_a?( Array ) &&
policies.first.type_name == 'policy'
controller.policies = policies # Set controller policies
forbidden = true
policies.each do | policy |
if policy.actions.include?( controller.action_name )
forbidden = false
end
end
end
end