Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass the session to the controller's last_request_update_allowed? method #377

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/authlogic/controller_adapters/abstract_adapter.rb
Expand Up @@ -54,8 +54,13 @@ def responds_to_last_request_update_allowed?
controller.respond_to?(:last_request_update_allowed?, true)
end

def last_request_update_allowed?
controller.send(:last_request_update_allowed?)
def last_request_update_allowed?(session)
case controller.method(:last_request_update_allowed?).arity
when 0
controller.send(:last_request_update_allowed?)
when 1
controller.send(:last_request_update_allowed?, session)
end
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/authlogic/session/magic_columns.rb
Expand Up @@ -71,14 +71,14 @@ def update_info
# session before it times out. Obviously you would want to ignore this request, because then the user would never time out.
# So you can do something like this in your controller:
#
# def last_request_update_allowed?
# def last_request_update_allowed?(session)
# action_name =! "update_session_time_left"
# end
#
# You can do whatever you want with that method.
def set_last_request_at? # :doc:
return false if !record || !klass.column_names.include?("last_request_at")
return controller.last_request_update_allowed? if controller.responds_to_last_request_update_allowed?
return controller.last_request_update_allowed?(self) if controller.responds_to_last_request_update_allowed?
record.last_request_at.blank? || last_request_at_threshold.to_i.seconds.ago >= record.last_request_at
end

Expand Down