From b8f6dd8cbb2de870a4805800fd89148a417bc612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 19 Dec 2010 09:30:46 +0100 Subject: Add missing require and remove extra module. --- activemodel/lib/active_model/secure_password.rb | 39 ++++++++++++------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index 3e7d3174ac..cd6256e3d6 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -1,3 +1,4 @@ +require 'active_support/core_ext/object/blank' require 'bcrypt' module ActiveModel @@ -43,30 +44,28 @@ module ActiveModel end end - module InstanceMethods - # Returns self if the password is correct, otherwise false. - def authenticate(unencrypted_password) - if BCrypt::Password.new(password_digest) == unencrypted_password - self - else - false - end + # Returns self if the password is correct, otherwise false. + def authenticate(unencrypted_password) + if BCrypt::Password.new(password_digest) == unencrypted_password + self + else + false end + end - # Encrypts the password into the password_digest attribute. - def password=(unencrypted_password) - @password = unencrypted_password - self.password_digest = BCrypt::Password.create(unencrypted_password) - end + # Encrypts the password into the password_digest attribute. + def password=(unencrypted_password) + @password = unencrypted_password + self.password_digest = BCrypt::Password.create(unencrypted_password) + end + private - private - def password_must_be_strong - if password.present? - errors.add(:password, "must be longer than 6 characters") unless password.size > 6 - errors.add(:password, "is too weak and common") if WEAK_PASSWORDS.include?(password) - end - end + def password_must_be_strong + if password.present? + errors.add(:password, "must be longer than 6 characters") unless password.size > 6 + errors.add(:password, "is too weak and common") if WEAK_PASSWORDS.include?(password) + end end end end \ No newline at end of file -- cgit v1.2.3