module Devise::Models::TokenAuthenticatable::ClassMethods

Public Instance Methods

authentication_token() click to toggle source

Generate a token checking if one does not already exist in the database.

# File lib/devise/token_authenticatable/model.rb, line 46
def authentication_token
  loop do
    token = Devise.friendly_token
    break token unless to_adapter.find_first({ authentication_token: token })
  end
end
find_for_token_authentication(conditions) click to toggle source
# File lib/devise/token_authenticatable/model.rb, line 36
def find_for_token_authentication(conditions)
  auth_conditions = conditions.dup
  authentication_token = auth_conditions.delete(Devise::TokenAuthenticatable.token_authentication_key)

  find_for_authentication(
    auth_conditions.merge(authentication_token: authentication_token)
  )
end