Sha256: 014af996cfd51d4adc424a4d8653aaaa36dac876ae6f2d14ce93f7efb7f30ce5

Contents?: true

Size: 442 Bytes

Versions: 9

Compression:

Stored size: 442 Bytes

Contents

class CASino::TwoFactorAuthenticator < ActiveRecord::Base
  belongs_to :user

  scope :active, -> { where(active: true) }

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

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
casino-4.1.2 app/models/casino/two_factor_authenticator.rb
casino-4.1.1 app/models/casino/two_factor_authenticator.rb
casino-4.1.0 app/models/casino/two_factor_authenticator.rb
casino-4.0.3 app/models/casino/two_factor_authenticator.rb
casino-4.0.2 app/models/casino/two_factor_authenticator.rb
casino-4.0.1 app/models/casino/two_factor_authenticator.rb
casino-4.0.0 app/models/casino/two_factor_authenticator.rb
casino-4.0.0.pre.2 app/models/casino/two_factor_authenticator.rb
casino-4.0.0.pre.1 app/models/casino/two_factor_authenticator.rb