login_token: lets constantize
This commit is contained in:
parent
5daa565a80
commit
7b935a6486
2 changed files with 4 additions and 2 deletions
|
@ -3,6 +3,8 @@ class Gestionnaire < ApplicationRecord
|
|||
include EmailSanitizableConcern
|
||||
include ActiveRecord::SecureToken
|
||||
|
||||
LOGIN_TOKEN_VALIDITY = 30.minutes
|
||||
|
||||
devise :database_authenticatable, :registerable, :async,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
|
@ -141,7 +143,7 @@ class Gestionnaire < ApplicationRecord
|
|||
|
||||
def login_token_valid?(login_token)
|
||||
BCrypt::Password.new(encrypted_login_token) == login_token &&
|
||||
30.minutes.ago < login_token_created_at
|
||||
LOGIN_TOKEN_VALIDITY.ago < login_token_created_at
|
||||
rescue BCrypt::Errors::InvalidHash
|
||||
false
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue