2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
2019-02-02 22:16:11 +01:00
|
|
|
|
2020-07-20 17:05:04 +02:00
|
|
|
belongs_to :instructeur, optional: false
|
2019-02-01 18:11:55 +01:00
|
|
|
has_secure_token
|
2019-02-02 22:16:11 +01:00
|
|
|
|
|
|
|
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
|