2020-08-06 16:35:45 +02:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: trusted_device_tokens
|
|
|
|
#
|
|
|
|
# id :bigint not null, primary key
|
2023-04-24 14:38:39 +02:00
|
|
|
# token :string
|
2020-08-06 16:35:45 +02:00
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
# instructeur_id :bigint
|
|
|
|
#
|
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
|