Permalink
Browse files

login redirects to referring page if exists

  • Loading branch information...
1 parent e11ac10 commit d1a71a12f66ab07cbaabf6230475890f6f547423 jrwest committed Mar 2, 2010
Showing with 2 additions and 1 deletion.
  1. +1 −1 app/controllers/authr/sessions_controller.rb
  2. +1 −0 lib/extensions/action_controller/base.rb
@@ -7,7 +7,7 @@ def create
if account = Account.authenticate(params[:account][:uname], params[:account][:password])
session[:account_id] = account.id
session[:account_login_time] = Time.now
- redirect_to '/'
+ redirect_to (session[:return_to]) ? session[:return_to] : '/'
else
redirect_to new_session_path
end
@@ -12,6 +12,7 @@ def self.skip_authentication!(options = {})
def authenticate_session
unless valid_session? || [new_session_path, session_path].include?(request.request_uri)
+ session[:return_to] = request.request_uri
redirect_to new_session_path
end
end

0 comments on commit d1a71a1

Please sign in to comment.