module Authlogic::Session::MagicColumns::InstanceMethods
The methods available for an Authlogic::Session::Base object that make up the magic columns feature.
Private Instance Methods
# File lib/authlogic/session/magic_columns.rb, line 43 def increase_failed_login_count if invalid_password? && attempted_record.respond_to?(:failed_login_count) attempted_record.failed_login_count ||= 0 attempted_record.failed_login_count += 1 end end
# File lib/authlogic/session/magic_columns.rb, line 89 def last_request_at_threshold self.class.last_request_at_threshold end
# File lib/authlogic/session/magic_columns.rb, line 85 def set_last_request_at record.last_request_at = klass.default_timezone == :utc ? Time.now.utc : Time.now end
This method lets authlogic know whether it should allow the last_request_at field to be updated with the current time (Time.now). One thing to note here is that it also checks for the existence of a last_request_update_allowed? method in your controller. This allows you to control this method pragmatically in your controller.
For example, what if you had a javascript function that polled the server updating how much time is left in their 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? action_name != "update_session_time_left" end
You can do whatever you want with that method.
# File lib/authlogic/session/magic_columns.rb, line 79 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? record.last_request_at.blank? || last_request_at_threshold.to_i.seconds.ago >= record.last_request_at end
# File lib/authlogic/session/magic_columns.rb, line 50 def update_info record.login_count = (record.login_count.blank? ? 1 : record.login_count + 1) if record.respond_to?(:login_count) record.failed_login_count = 0 if record.respond_to?(:failed_login_count) if record.respond_to?(:current_login_at) record.last_login_at = record.current_login_at if record.respond_to?(:last_login_at) record.current_login_at = klass.default_timezone == :utc ? Time.now.utc : Time.now end if record.respond_to?(:current_login_ip) record.last_login_ip = record.current_login_ip if record.respond_to?(:last_login_ip) record.current_login_ip = controller.request.ip end end