Class: CASinoCore::Model::TwoFactorAuthenticator

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/casino_core/model/two_factor_authenticator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cleanupObject



8
9
10
# File 'lib/casino_core/model/two_factor_authenticator.rb', line 8

def self.cleanup
  self.delete_all(['(created_at < ?) AND active = ?', self.lifetime.ago, false])
end

.lifetimeObject



12
13
14
# File 'lib/casino_core/model/two_factor_authenticator.rb', line 12

def self.lifetime
  CASinoCore::Settings.two_factor_authenticator[:lifetime_inactive].seconds
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/casino_core/model/two_factor_authenticator.rb', line 16

def expired?
  !self.active? && (Time.now - (self.created_at || Time.now)) > self.class.lifetime
end