lib/padrino-admin/generators/templates/account/mongomapper.rb.tt in padrino-admin-0.9.21 vs lib/padrino-admin/generators/templates/account/mongomapper.rb.tt in padrino-admin-0.9.22

- old
+ new

@@ -19,11 +19,11 @@ validates_uniqueness_of :email, :case_sensitive => false validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i validates_format_of :role, :with => /[A-Za-z]/ # Callbacks - before_save :generate_password + before_save :encrypt_password, :if => :password_required ## # This method is for authentication purpose # def self.authenticate(email, password) @@ -34,13 +34,13 @@ def has_password?(password) ::BCrypt::Password.new(crypted_password) == password end private - def generate_password + def encrypt_password self.crypted_password = ::BCrypt::Password.create(password) end def password_required - crypted_password.blank? || !password.blank? + crypted_password.blank? || password.present? end -end \ No newline at end of file +end