module Devise::Models::TokenAuthenticatable

Public Class Methods

required_fields(klass) click to toggle source
# File lib/metova/devise/models/token_authenticatable.rb, line 12
def self.required_fields(klass)
  [:authentication_token, :token_expires_at]
end

Public Instance Methods

ensure_authentication_token!() click to toggle source
# File lib/metova/devise/models/token_authenticatable.rb, line 29
def ensure_authentication_token!
  reset_authentication_token! if authentication_token.blank? || token_expired?
end
expire_token_in() click to toggle source
# File lib/metova/devise/models/token_authenticatable.rb, line 37
def expire_token_in
  14.days
end
reset_authentication_token() click to toggle source
# File lib/metova/devise/models/token_authenticatable.rb, line 16
def reset_authentication_token
  self.authentication_token = loop do
    token = Devise.friendly_token
    break token unless self.class.exists?(authentication_token: token)
  end
  self.token_expires_at = Time.current + expire_token_in
end
reset_authentication_token!() click to toggle source
# File lib/metova/devise/models/token_authenticatable.rb, line 24
def reset_authentication_token!
  reset_authentication_token
  save validate: false
end
token_expired?() click to toggle source
# File lib/metova/devise/models/token_authenticatable.rb, line 33
def token_expired?
  token_expires_at.nil? || token_expires_at.past?
end