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)


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

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

#encrypt(password) ⇒ Object

Encrypts the password with the user salt



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

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

#encrypt_passwordObject

before filter



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

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)


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

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