diff options
Diffstat (limited to 'actionpack/lib/action_controller/authentication.rb')
-rw-r--r-- | actionpack/lib/action_controller/authentication.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/authentication.rb b/actionpack/lib/action_controller/authentication.rb index 3ba193c1b2..f4ccde20ca 100644 --- a/actionpack/lib/action_controller/authentication.rb +++ b/actionpack/lib/action_controller/authentication.rb @@ -34,9 +34,11 @@ module ActionController #:nodoc: # # Options are: # * <tt>:by</tt> - the code fragment that will be evaluated on each request to determine whether the request is authenticated. + # * <tt>:before</tt> - a code fragment that's run before the failure redirect happens, such as + # '@session[:return_to] = @request.request_uri'. # * <tt>:failure</tt> - redirection options following the format of Base#url_for. def authentication(options) - options.assert_valid_keys([:by, :failure]) + options.assert_valid_keys([:by, :failure, :before]) class_eval <<-EOV protected def actions_excepted_from_authentication @@ -71,6 +73,7 @@ module ActionController #:nodoc: if !action_needs_authentication? || #{options[:by]} return true else + #{options[:before]} redirect_to(#{options[:failure].inspect}) return false end |