aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorRhenium <rhenium@rhe.jp>2014-01-23 06:46:24 +0900
committerRhenium <rhenium@rhe.jp>2014-01-23 06:46:24 +0900
commit5d05e40f57ae0c7406353d6b888e17e4cb944a62 (patch)
tree4e4a3d75db004472961cb5c1b0bdbdf4e91713a2 /app/controllers/application_controller.rb
parentced686186bc3f4d2f36d55580fac34a5a9fdc2f7 (diff)
downloadaclog-5d05e40f57ae0c7406353d6b888e17e4cb944a62.tar.gz
move TwitterOauthEchoAuthentication to app/controllers/concerns
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb20
1 files changed, 12 insertions, 8 deletions
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?