1class AdminUserSession < Authlogic::Session::Base
 
2  allow_http_basic_auth false
 
3  consecutive_failed_logins_limit AdminUser::DISABLED_LOGIN_COUNT
 
4  logout_on_timeout true
 
5
 
6  before_save do
 
7    record.reset_persistence_token!
 
8  end
 
 9
 
10  before_destroy do
 
11    if stale?
 
12      stale_record.reset_persistence_token!
 
13    else
 
14      record.reset_persistence_token!
 
15    end
 
16  end
 
  • Complexity 1 » saikuro
18  def last_login_attempt?
 
19    failed_login_count == consecutive_failed_logins_limit - 1
 
20  end
 
  • Complexity 2 » saikuro
22  def time_remaining
 
23    record ? record.time_remaining : 0
 
24  end
 
 
26  private
 
  • Complexity 2 » saikuro
28  def failed_login_count
 
29    attempted_record.present? ? attempted_record.failed_login_count : 0
 
30  end
 
31end