Class: Relay::Models::User

Inherits:
Sequel::Model
  • Object
show all
Includes:
Relay::Model
Defined in:
app/models/user.rb

Instance Method Summary collapse

Methods included from Relay::Model

included

Instance Method Details

#authenticate(value) ⇒ Relay::Models::User, false

Authenticates the given plaintext password.

Parameters:

  • value (String)

Returns:



23
24
25
26
27
28
29
# File 'app/models/user.rb', line 23

def authenticate(value)
  return false if password_digest.to_s.empty?

  BCrypt::Password.new(password_digest) == value && self
rescue BCrypt::Errors::InvalidHash
  false
end

#password=(value) ⇒ Object

Hashes and stores the given password.

Parameters:

  • value (String)


14
15
16
17
# File 'app/models/user.rb', line 14

def password=(value)
  @password = value
  self.password_digest = BCrypt::Password.create(value)
end