mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Refactor session expire method
This commit is contained in:
parent
0e3000b2c5
commit
0150e9f2c3
1 changed files with 16 additions and 19 deletions
|
|
@ -45,23 +45,20 @@ 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
|
# If the method is called by the feed controller (which we don't have
|
||||||
return if self.controller_name == 'feed' or session['noexpiry'] == "on"
|
# under session control) or if we checked the box to keep logged in on
|
||||||
# If the method is called by the feed controller (which we don't have
|
# login don't set the session expiry time.
|
||||||
# under session control) or if we checked the box to keep logged in on
|
return if session.nil? || self.controller_name == 'feed' || session['noexpiry'] == "on"
|
||||||
# login don't set the session expiry time.
|
|
||||||
if session
|
# 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
|
if expiry_time < Time.now
|
||||||
if expiry_time < Time.now
|
# Too late, matey... bang goes your session!
|
||||||
# Too late, matey... bang goes your session!
|
reset_session
|
||||||
reset_session
|
else
|
||||||
else
|
# Okay, you get another hour
|
||||||
# Okay, you get another hour
|
session['expiry_time'] = Time.now + (60*60)
|
||||||
session['expiry_time'] = Time.now + (60*60)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -159,7 +156,7 @@ class ApplicationController < ActionController::Base
|
||||||
super # handle xml http auth via our own login code
|
super # handle xml http auth via our own login code
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sanitize(arg)
|
def sanitize(arg)
|
||||||
ActionController::Base.helpers.sanitize(arg)
|
ActionController::Base.helpers.sanitize(arg)
|
||||||
end
|
end
|
||||||
|
|
@ -272,7 +269,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def all_done_todos_for(object)
|
def all_done_todos_for(object)
|
||||||
object_name = object.class.name.downcase # context or project
|
object_name = object.class.name.downcase # context or project
|
||||||
@source_view = object_name
|
@source_view = object_name
|
||||||
@page_title = t("#{object_name.pluralize}.all_completed_tasks_title", "#{object_name}_name".to_sym => object.name)
|
@page_title = t("#{object_name.pluralize}.all_completed_tasks_title", "#{object_name}_name".to_sym => object.name)
|
||||||
|
|
||||||
@done = object.todos.completed.paginate :page => params[:page], :per_page => 20, :order => 'completed_at DESC', :include => Todo::DEFAULT_INCLUDES
|
@done = object.todos.completed.paginate :page => params[:page], :per_page => 20, :order => 'completed_at DESC', :include => Todo::DEFAULT_INCLUDES
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue