Module: Toll::Models::Authenticable

Defined in:
lib/toll/models/authenticable.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_with_tokenObject Also known as: sign_out

Method to authenticate the user It only updates the token

We are making sure the user is a valid record, that’s why the ‘save` call



32
33
34
35
36
# File 'lib/toll/models/authenticable.rb', line 32

def authenticate_with_token
  generate_authentication_token!
  save
  self
end

#update_authentication_token!Object

Updates the record but:

  • Validations are skipped.

  • Callbacks are skipped.

  • updated_at/updated_on are not updated.



22
23
24
25
# File 'lib/toll/models/authenticable.rb', line 22

def update_authentication_token!
  generate_authentication_token!
  update_column(Toll.authentication_token_attribute_name, self.send(Toll.authentication_token_attribute_name))
end

#update_authentication_token_without_validationsObject

Updates the record authentication but:

  • Validation is skipped.

  • Callbacks are invoked.

  • updated_at/updated_on column is updated if that column is available.

  • Updates all the attributes that are dirty in this object.



12
13
14
15
# File 'lib/toll/models/authenticable.rb', line 12

def update_authentication_token_without_validations
  generate_authentication_token!
  update_attribute(Toll.authentication_token_attribute_name, self.send(Toll.authentication_token_attribute_name))
end