lib/twitter_auth/controller_extensions.rb in mbleigh-twitter-auth-0.1.21 vs lib/twitter_auth/controller_extensions.rb in mbleigh-twitter-auth-0.1.22

- old
+ new

@@ -14,15 +14,22 @@ redirect_to destination end def authentication_succeeded(message = 'You have logged in successfully.', destination = '/') flash[:notice] = message - redirect_to destination + redirect_back_or_default destination end def current_user - @current_user ||= User.find_by_id(session[:user_id]) || User.from_remember_token(cookies[:remember_token]) + @current_user ||= + if session[:user_id] + User.find_by_id(session[:user_id]) + elsif cookies[:remember_token] + User.from_remember_token(cookies[:remember_token]) + else + false + end end def current_user=(new_user) session[:user_id] = new_user.id @current_user = new_user @@ -53,11 +60,11 @@ def logged_in? !!current_user end def logout_keeping_session! - @current_user = nil session[:user_id] = nil + @current_user = nil cookies.delete(:remember_token) end end end