Module: Agilib::TokenAuthenticatable

Extended by:
ActiveSupport::Concern
Defined in:
lib/agilib/token_authenticatable/token_authentication.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

@@secure_token =
true
@@auth_params =
{
  :user_token => :user_token,
  :user_email => :user_email
}
@@login_params =
{
  :login     => :email,      
  :password  => :password
}
@@route =
"/tokens"

Instance Method Summary collapse

Instance Method Details

#ensure_authentication_tokenObject



31
32
33
34
35
# File 'lib/agilib/token_authenticatable/token_authentication.rb', line 31

def ensure_authentication_token
  if authentication_token.blank?
    self.authentication_token = generate_authentication_token
  end
end

#generate_authentication_tokenObject



37
38
39
40
41
42
# File 'lib/agilib/token_authenticatable/token_authentication.rb', line 37

def generate_authentication_token
  loop do
    token = Devise.friendly_token
    break token unless User.where(authentication_token: token).first
  end
end