Forum: Ruby on Rails Possible acts_as_authenticated bug (or rails)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
PJ Hyett (Guest)
on 2006-04-26 04:03
(Received via mailing list)
The code that comes with the plugin uses a method that looks like this:

def password_required?
    crypted_password.blank? or not password.blank?
 end

with validations that look like this:

  validates_presence_of     :password,                   :if =>
:password_required?
  validates_presence_of     :password_confirmation,      :if =>
:password_required?
  validates_length_of       :password, :within => 5..40, :if =>
:password_required?
  validates_confirmation_of :password,                   :if =>
:password_required?

I though the validations_presence_of :password_confirmation was a bit
redundant, so I removed it. Unfortunately, that breaks the
password_required? method. Here's how I fixed it:

def password_required?
    logger.debug('hi')
    crypted_password.blank? or not password.blank?
end

I added a debug statement, that's it. What am I missing?

And why do I still need check the presence of the confirmation field,
isn't that the purpose of validates_confirmation_of?

Thanks,
PJ
Daniel -. (Guest)
on 2006-04-27 04:05
(Received via mailing list)
I had a problem with this method as well, but it was a while ago and the
exact details escape me at the moment..  I was only playing and my site
wasn't ever going into production.

The way I got around was to remove the not condition on password.blank?
in
the password_required? method.

I don't know the ramifications of this I never really studied it much
but it
allowed me to continue to play.

If someone out there knows what impact this has I would surely like to
hear.

Cheer
This topic is locked and can not be replied to.