Module: DeviseRailsApiAuthentication::Authenticatable

Extended by:
ActiveSupport::Concern
Defined in:
lib/devise_rails_api_authentication/authenticatable.rb

Instance Method Summary collapse

Instance Method Details

#ensure_authentication_tokenObject



12
13
14
15
16
# File 'lib/devise_rails_api_authentication/authenticatable.rb', line 12

def ensure_authentication_token
  return unless authentication_token.blank?

  self.authentication_token = generate_authentication_token
end

#generate_authentication_tokenObject



18
19
20
21
22
23
# File 'lib/devise_rails_api_authentication/authenticatable.rb', line 18

def generate_authentication_token
  loop do
    token = Devise.friendly_token
    break token if self.class.where(authentication_token: token).count == 0
  end
end