views:

1272

answers:

4

I'm getting a similar error to this post http://stackoverflow.com/questions/1475128/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 = "[email protected]"
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?

+2  A: 

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
guess who answered a question...
ThinkBohemian
+1  A: 

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.

Timberford
A: 

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

#  before_save :encrypt_password
cactis