Class: AuthApi::User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AuthApi::User
- Defined in:
- app/models/auth_api/user.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'app/models/auth_api/user.rb', line 7 def password @password end |
Class Method Details
.authenticate(email, password) ⇒ Object
15 16 17 18 |
# File 'app/models/auth_api/user.rb', line 15 def self.authenticate(email, password) user = where(email: email).first user and user.password_hash == BCrypt::Engine.hash_secret(password, user.password_salt) ? user : nil end |
Instance Method Details
#encrypt_password ⇒ Object
10 11 12 13 |
# File 'app/models/auth_api/user.rb', line 10 def encrypt_password self.password_salt = ::BCrypt::Engine.generate_salt self.password_hash = ::BCrypt::Engine.hash_secret(password, password_salt) end |