aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2010-12-29 10:18:14 -0800
committerDavid Heinemeier Hansson <david@loudthinking.com>2010-12-29 10:18:14 -0800
commit43433b3fb4b9c054e0bcaaa1f7456b3fececd268 (patch)
tree27f667d8bb1cf56ba79d6a6202c6690ce11961e2 /activemodel
parentfd1cf13f743ac7ba71f19dff6d8e22f5ac7bc603 (diff)
downloadrails-43433b3fb4b9c054e0bcaaa1f7456b3fececd268.tar.gz
rails-43433b3fb4b9c054e0bcaaa1f7456b3fececd268.tar.bz2
rails-43433b3fb4b9c054e0bcaaa1f7456b3fececd268.zip
Instance methods shouldnt be added until you actually call has_secure_password
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/secure_password.rb26
1 files changed, 15 insertions, 11 deletions
diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb
index 52941942b8..7e8370a04c 100644
--- a/activemodel/lib/active_model/secure_password.rb
+++ b/activemodel/lib/active_model/secure_password.rb
@@ -37,22 +37,26 @@ module ActiveModel
validates_confirmation_of :password
validates_presence_of :password_digest
+
+ include InstanceMethodsOnActivation
end
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
+ module InstanceMethodsOnActivation
+ # 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
- end
- # Encrypts the password into the password_digest attribute.
- def password=(unencrypted_password)
- @password = unencrypted_password
- self.password_digest = BCrypt::Password.create(unencrypted_password)
+ # Encrypts the password into the password_digest attribute.
+ def password=(unencrypted_password)
+ @password = unencrypted_password
+ self.password_digest = BCrypt::Password.create(unencrypted_password)
+ end
end
end
end