Class: CASino::TwoFactorAuthenticator

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/casino/two_factor_authenticator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cleanupObject


7
8
9
# File 'app/models/casino/two_factor_authenticator.rb', line 7

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

.lifetimeObject


11
12
13
# File 'app/models/casino/two_factor_authenticator.rb', line 11

def self.lifetime
  CASino.config.two_factor_authenticator[:lifetime_inactive].seconds
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)

15
16
17
# File 'app/models/casino/two_factor_authenticator.rb', line 15

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