Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

authority_success logging #119

Merged
merged 5 commits into from
Feb 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/authority/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ def authorize_action_for(authority_resource, *options)
end

Authority.enforce(authority_action, authority_resource, authority_user, *options)

# This method is always invoked, but will only log if it's overriden
authority_success(authority_user, authority_action, authority_resource)

self.authorization_performed = true
end

Expand All @@ -144,6 +148,11 @@ def authority_forbidden(error)
render :file => Rails.root.join('public', '403.html'), :status => 403, :layout => false
end

# This method can be overloaded inside the application controller, similar to authority_forbidden.
def authority_success(user, action, resource)
# Do nothing by default, but provide the option for users to override if they will.
end

private

# The `before_filter` that will be setup to run when the class method
Expand Down