lib/authority/controller.rb in authority-3.2.2 vs lib/authority/controller.rb in authority-3.3.0
- old
+ new
@@ -131,18 +131,27 @@
if authority_action.nil?
raise MissingAction.new("No authority action defined for #{action_name}")
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
# Renders a static file to minimize the chances of further errors.
#
# @param [Exception] error, an error that indicates the user tried to perform a forbidden action.
def authority_forbidden(error)
Authority.logger.warn(error.message)
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