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

Commit

Permalink
Merge pull request #119 from forced-request/logAuthz
Browse files Browse the repository at this point in the history
authority_success logging
  • Loading branch information
nathanl authored Feb 7, 2017
2 parents e92d538 + fb86bd9 commit 4c1fd89
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit 4c1fd89

Please sign in to comment.