Class: KktShoppe::User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- KktShoppe::User
- Defined in:
- app/models/kkt_shoppe/user.rb
Class Method Summary collapse
-
.authenticate(email_address, password) ⇒ KktShoppe::User
Attempt to authenticate a user based on email & password.
Instance Method Summary collapse
-
#full_name ⇒ String
The user’s first name & last name concatenated.
-
#reset_password! ⇒ Object
Reset the user’s password to something random and e-mail it to them.
-
#short_name ⇒ String
The user’s first name & initial of last name concatenated.
Class Method Details
.authenticate(email_address, password) ⇒ KktShoppe::User
Attempt to authenticate a user based on email & password. Returns the user if successful otherwise returns false.
41 42 43 44 45 46 |
# File 'app/models/kkt_shoppe/user.rb', line 41 def self.authenticate(email_address, password) user = self.where(:email_address => email_address).first return false if user.nil? return false unless user.authenticate(password) user end |
Instance Method Details
#full_name ⇒ String
The user’s first name & last name concatenated
16 17 18 |
# File 'app/models/kkt_shoppe/user.rb', line 16 def full_name "#{first_name} #{last_name}" end |
#reset_password! ⇒ Object
Reset the user’s password to something random and e-mail it to them
28 29 30 31 32 33 |
# File 'app/models/kkt_shoppe/user.rb', line 28 def reset_password! self.password = SecureRandom.hex(8) self.password_confirmation = self.password self.save! KktShoppe::UserMailer.new_password(self).deliver_now end |
#short_name ⇒ String
The user’s first name & initial of last name concatenated
23 24 25 |
# File 'app/models/kkt_shoppe/user.rb', line 23 def short_name "#{first_name} #{last_name[0,1]}" end |