1

I'm getting a similar error to this post Ruby on Rails Authlogic password not valid "Password is not valid" which never seemed to be resolved

in the script/console if I create a new user:

myval = "foo@example.com"
u = User.create(:email => myval, :password => myval, :password_confirmation => myval)
u.valid? 
>> true
u.save
>> true
u.valid_password?(myval)
>>false

if i set in my user.rb:

acts_as_authentic  do |c|
   c.validate_password_field = false
end

i get the same response. Any suggestions?

Community
  • 1
  • 1
Schneems
  • 14,918
  • 9
  • 57
  • 84
  • Never forget to check your migrations, and when all else fails find a project that works and work backwards. I was using a weird mix of authlogic and restful authentication migration. – Schneems Oct 04 '09 at 16:37
  • Did my answer help you in figuring out this issue? If so, please accept it (and uprate it, if you desire). So far out of 7 question you've asked you've yet to accept an answer on any of them. – Peter Wagenet Oct 05 '09 at 13:40
  • Alas i don't have the required 15 points to vote you up, if someone else comes on upon this post can you please give peter his due. Unless i'm missing some hidden "accept solution" button that is. – Schneems Oct 06 '09 at 02:08

4 Answers4

4

I just took a dig through the AuthLogic code and it looks like setting validate_password_field to false only prevents Rails from running the default validations. It has no effect on the valid_password? method.

There are a number of other factors that appear to cause it to return false. These include but may not be limited to:

  • Checking for a blank password
  • The crypted password is blank
  • The password doesn't match. (This one is a bit complicated because there are a variety of factors involved in this, including the CryptoProvider and whether or not you're using RestfulAuthentication style passwords.)

To give a more definitive answer, I probably need some more information on your exact setup.

Peter Wagenet
  • 4,976
  • 22
  • 26
2

I had a similar problem to this, turns out the old Restful Authentication password fields are migrated at 40 characters in length when Authlogic requires 255.

Paul Sturgess
  • 3,254
  • 2
  • 23
  • 22
  • Thank you for this! I had the same problem and was running out of ideas.... Updating my DB field from 40 to 255 did the trick. – fredw Apr 13 '11 at 21:47
1

In my case it was just a messed up data base migration. rake db:migrate VERSION=0 && rake db:migrate solved this problem for me.

dStulle
  • 609
  • 5
  • 24
0

try to remark "before_save :encrypt_password" in user.rb if you have.

#  before_save :encrypt_password
cactis
  • 205
  • 5
  • 5