提交 43433b3f 编写于 作者: D David Heinemeier Hansson

Instance methods shouldnt be added until you actually call has_secure_password

上级 fd1cf13f
......@@ -37,9 +37,12 @@ def has_secure_password
validates_confirmation_of :password
validates_presence_of :password_digest
include InstanceMethodsOnActivation
end
end
module InstanceMethodsOnActivation
# Returns self if the password is correct, otherwise false.
def authenticate(unencrypted_password)
if BCrypt::Password.new(password_digest) == unencrypted_password
......@@ -55,4 +58,5 @@ def password=(unencrypted_password)
self.password_digest = BCrypt::Password.create(unencrypted_password)
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册