Module: Devise::Models::TokenAuthenticatable::ClassMethods

Defined in:
lib/devise/token_authenticatable/model.rb

Instance Method Summary collapse

Instance Method Details

#authentication_tokenObject

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



46
47
48
49
50
51
# 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) ⇒ Object



36
37
38
39
40
41
42
43
# 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