demarches-normaliennes/app/models/trusted_device_token.rb

16 lines
310 B
Ruby
Raw Normal View History

2019-02-01 18:11:55 +01:00
class TrustedDeviceToken < ApplicationRecord
2019-02-12 17:35:19 +01:00
LOGIN_TOKEN_VALIDITY = 1.week
2019-02-04 11:04:55 +01:00
LOGIN_TOKEN_YOUTH = 15.minutes
belongs_to :instructeur, optional: false
2019-02-01 18:11:55 +01:00
has_secure_token
def token_valid?
LOGIN_TOKEN_VALIDITY.ago < created_at
end
2019-02-04 11:04:55 +01:00
def token_young?
LOGIN_TOKEN_YOUTH.ago < created_at
end
2019-02-01 18:11:55 +01:00
end