summaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-08-14 21:50:28 -0600
committermo khan <mo@mokhan.ca>2014-08-14 21:50:28 -0600
commitca229eeaed04c55aa0bff12a39692d85033f60ec (patch)
tree1a5050bd1f2a36744841f89d813715589e8ead02 /app/controllers/application_controller.rb
parentd104be0fe0fb427d945fcab211b7253e3c4239a9 (diff)
extend cookie session for each request.
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 67b9c69c..c460a5a2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -4,10 +4,11 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_filter :load_header
before_filter :configure_permitted_parameters, if: :devise_controller?
+ before_filter :extend_session_cookie
helper_method :current_user, :user_signed_in?
def user_session(session_key = cookies.signed[:cookie_monster])
- UserSession.authenticate(session_key)
+ @user_session ||= UserSession.authenticate(session_key)
end
def current_user
@@ -36,4 +37,8 @@ class ApplicationController < ActionController::Base
def authenticate!
redirect_to new_session_path unless user_session
end
+
+ def extend_session_cookie
+ cookies.signed[:cookie_monster] = user_session.access(request) if user_signed_in?
+ end
end