Class: User
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- User
- Defined in:
- lib/templates/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.
23 24 25 |
# File 'lib/templates/user.rb', line 23 def password @password end |
Class Method Details
.find_by_credentials(username, password) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/templates/user.rb', line 13 def self.find_by_credentials(username, password) user = User.find_by(username: username) return nil if user.nil? if user.is_password?(password) return user else return nil end end |
.token ⇒ Object
9 10 11 |
# File 'lib/templates/user.rb', line 9 def self.token SecureRandom::urlsafe_base64(16) end |
Instance Method Details
#digest(string) ⇒ Object
30 31 32 |
# File 'lib/templates/user.rb', line 30 def digest(string) string_digest = BCrypt::Password.create(string) end |
#is_password?(password) ⇒ Boolean
34 35 36 |
# File 'lib/templates/user.rb', line 34 def is_password?(password) BCrypt::Password.new(self.password_digest).is_password?(password) end |