aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-12-19 09:30:46 +0100
committerJosé Valim <jose.valim@gmail.com>2010-12-19 09:31:26 +0100
commitb8f6dd8cbb2de870a4805800fd89148a417bc612 (patch)
tree59717f5902cdf0dd810798579ad5da318de7c86d /activemodel/lib
parentd592fa946d43fdadf23f872a5c3334fb4f108f80 (diff)
downloadrails-b8f6dd8cbb2de870a4805800fd89148a417bc612.tar.gz
rails-b8f6dd8cbb2de870a4805800fd89148a417bc612.tar.bz2
rails-b8f6dd8cbb2de870a4805800fd89148a417bc612.zip
Add missing require and remove extra module.
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/secure_password.rb39
1 files changed, 19 insertions, 20 deletions
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