Module: OmniAuth::Identity::SecurePassword::InstanceMethodsOnActivation

Defined in:
lib/omniauth/identity/secure_password.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(unencrypted_password) ⇒ Object

Returns self if the password is correct, otherwise false.



60
61
62
63
64
65
66
# File 'lib/omniauth/identity/secure_password.rb', line 60

def authenticate(unencrypted_password)
  if BCrypt::Password.new(password_digest) == unencrypted_password
    self
  else
    false
  end
end

#password=(unencrypted_password) ⇒ Object

Encrypts the password into the password_digest attribute.



69
70
71
72
73
74
# File 'lib/omniauth/identity/secure_password.rb', line 69

def password=(unencrypted_password)
  @password = unencrypted_password
  unless unencrypted_password.empty?
    self.password_digest = BCrypt::Password.create(unencrypted_password)
  end
end