From 5d05e40f57ae0c7406353d6b888e17e4cb944a62 Mon Sep 17 00:00:00 2001 From: Rhenium Date: Thu, 23 Jan 2014 06:46:24 +0900 Subject: move TwitterOauthEchoAuthentication to app/controllers/concerns --- app/controllers/application_controller.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c223366..b756c2f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,5 @@ class ApplicationController < ActionController::Base - include Aclog::TwitterOauthEchoAuthentication::ControllerMethods + include TwitterOauthEchoAuthentication protect_from_forgery after_action :set_content_type_to_xhtml, :tidy_response_body @@ -8,14 +8,18 @@ class ApplicationController < ActionController::Base protected def current_user - if session[:user_id] - User.find(session[:user_id]) - elsif request.headers["X-Verify-Credentials-Authorization"] - user_id = authenticate_with_twitter_oauth_echo - User.find(user_id) + return @_current_user if defined? @_current_user + + @_current_user = begin + if session[:user_id] + User.find(session[:user_id]) + elsif request.headers["X-Verify-Credentials-Authorization"] + user_id = authenticate_with_twitter_oauth_echo + User.find(user_id) + end + rescue + nil end - rescue - nil end def logged_in? -- cgit v1.2.3