demarches-normaliennes/app/models/trusted_device_token.rb

26 lines
595 B
Ruby
Raw Normal View History

2020-08-06 16:35:45 +02:00
# == Schema Information
#
# Table name: trusted_device_tokens
#
# id :bigint not null, primary key
# token :string not null
# 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
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