Module: Authentication::ByPassword::ModelInstanceMethods

Defined in:
lib/authentication/by_password.rb

Overview

Instance Methods

Instance Method Summary collapse

Instance Method Details

#authenticated?(password) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/authentication/by_password.rb', line 50

def authenticated?(password)
  crypted_password == encrypt(password)
end

#encrypt(password) ⇒ Object

Encrypts the password with the user salt



46
47
48
# File 'lib/authentication/by_password.rb', line 46

def encrypt(password)
  self.class.password_digest(password, salt)
end

#encrypt_passwordObject

before filter



55
56
57
58
59
# File 'lib/authentication/by_password.rb', line 55

def encrypt_password
  return if password.blank?
  self.salt = self.class.make_token if new_record?
  self.crypted_password = encrypt(password)
end

#password_required?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/authentication/by_password.rb', line 60

def password_required?
  crypted_password.blank? || !password.blank?
end