Module: Sequel::Plugins::SecurePassword::InstanceMethods

Defined in:
lib/sequel/plugins/secure_password.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



36
37
38
# File 'lib/sequel/plugins/secure_password.rb', line 36

def password
  @password
end

#password_confirmationObject

Returns the value of attribute password_confirmation.



35
36
37
# File 'lib/sequel/plugins/secure_password.rb', line 35

def password_confirmation
  @password_confirmation
end

Instance Method Details

#authenticate(unencrypted) ⇒ Object



46
47
48
49
50
# File 'lib/sequel/plugins/secure_password.rb', line 46

def authenticate(unencrypted)
  if BCrypt::Password.new(self.send(model.digest_column)) == unencrypted
    self
  end
end

#validateObject



52
53
54
55
56
57
58
59
# File 'lib/sequel/plugins/secure_password.rb', line 52

def validate
  super

  if model.include_validations
    errors.add :password, 'is not present'              if SecurePassword.blank_string?(self.send(model.digest_column))
    errors.add :password, 'doesn\'t match confirmation' if password != password_confirmation
  end
end