Browse files

improved login

  • Loading branch information...
1 parent bf78b17 commit 614a594b44ba175dd41e00de9b2ca0a98b25db5c @mooktakim committed Dec 3, 2010
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/extensions/action_controller/base.rb
View
8 lib/extensions/action_controller/base.rb
@@ -38,7 +38,7 @@ def redirect_back_or_default(default)
end
def current_user
- @current_user ||= session_login || cookie_login
+ @current_user ||= (session_login || cookie_login)
rescue
logout!
end
@@ -50,8 +50,9 @@ def session_login
def cookie_login
return nil if cookies.signed[:remember_token].blank?
user = User.where(:remember_token => cookies.signed[:remember_token]).first
- session[:user_id] = user.id if user
- user
+ current_user = user if user
+ rescue
+ nil
end
def current_user?
@@ -67,7 +68,6 @@ def current_user=(user)
end
def logout!
- @current_user.try(:forget)
@current_user = nil
session.delete(:user_id)
session.delete(:return_to)

0 comments on commit 614a594

Please sign in to comment.