Refactor session expire method

This commit is contained in:
Andrius Janauskas 2013-09-13 16:01:54 +03:00
parent 0e3000b2c5
commit 0150e9f2c3

View file

@ -45,12 +45,11 @@ class ApplicationController < ActionController::Base
def set_session_expiration def set_session_expiration
# http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions # http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions
unless session == nil
return if self.controller_name == 'feed' or session['noexpiry'] == "on"
# If the method is called by the feed controller (which we don't have # If the method is called by the feed controller (which we don't have
# under session control) or if we checked the box to keep logged in on # under session control) or if we checked the box to keep logged in on
# login don't set the session expiry time. # login don't set the session expiry time.
if session return if session.nil? || self.controller_name == 'feed' || session['noexpiry'] == "on"
# Get expiry time (allow ten seconds window for the case where we have # Get expiry time (allow ten seconds window for the case where we have
# none) # none)
expiry_time = session['expiry_time'] || Time.now + 10 expiry_time = session['expiry_time'] || Time.now + 10
@ -62,8 +61,6 @@ class ApplicationController < ActionController::Base
session['expiry_time'] = Time.now + (60*60) session['expiry_time'] = Time.now + (60*60)
end end
end end
end
end
# Redirects to change_password_user_path if the current user uses a # Redirects to change_password_user_path if the current user uses a
# deprecated password hashing algorithm. # deprecated password hashing algorithm.