Skip to content
Browse files

Add missing require and remove extra module.

  • Loading branch information...
1 parent d592fa9 commit b8f6dd8cbb2de870a4805800fd89148a417bc612 @josevalim josevalim committed Dec 19, 2010
Showing with 19 additions and 20 deletions.
  1. +19 −20 activemodel/lib/active_model/secure_password.rb
View
39 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 @@ def has_secure_password
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

0 comments on commit b8f6dd8

Please sign in to comment.
Something went wrong with that request. Please try again.