Skip to content
Browse files

was not reading signed cookies correct, need to use cookies.signed[:r…

…emember_token]
  • Loading branch information...
1 parent 987d6b0 commit a411ae2dccc13eea8fb717d37d0ce1646810a554 @mooktakim committed Dec 3, 2010
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/extensions/action_controller/base.rb
View
11 lib/extensions/action_controller/base.rb
@@ -41,7 +41,7 @@ def current_user
@current_user ||= if session[:user_id]
User.find(session[:user_id])
elsif cookies[:remember_token]
- User.find_by_remember_token(cookies[:remember_token])
+ User.find_by_remember_token(cookies.signed[:remember_token])
end
rescue
logout!
@@ -54,16 +54,17 @@ def current_user?
def current_user=(user)
user.tap do |user|
user.remember
- session[:user_id] = user.id
+ session[:user_id] = user.id
cookies.permanent.signed[:remember_token] = user.remember_token
end
end
def logout!
- session[:user_id] = nil
- @current_user = nil
+ @current_user.try(:forget)
+ @current_user = nil
+ session.delete(:user_id)
+ session.delete(:return_to)
cookies.delete(:remember_token)
- session[:return_to] = nil
end
end

0 comments on commit a411ae2

Please sign in to comment.
Something went wrong with that request. Please try again.