views:

852

answers:

3

I am trying to implement Authlogic. Registering is fine, it enters all the necessary details into my database..

.. but when I try to log in, it gives me the error:

1 error prohibited this user session from being saved

There were problems with the following fields:

Password is not valid

My password is valid. I am not sure what is happening. Any ideas?

A: 

In your user model, try this:

class User < ActiveRecord::Base

  acts_as_authentic do |c|
    c.validate_password_field = false
  end

end

Then try to log in again. If that works, then you will know that the authlogic default validations were tripping you up.

You can also try

valid_password?(attempted_password, check_against_database = check_passwords_against_database?)

with the console

epid
+2  A: 

I had the same problem, and it was because I was migrating from Restful authentication. The issue was: Restful authentication puts a 40 char cap on password-salt and crypted-password. the hashes generated by authlogic are larger than that.

class RemovePasswordSaltCap < ActiveRecord::Migration
  def self.up
    change_column :users, :password_salt, :string, :limit => nil
    change_column :users, :crypted_password, :string, :limit => nil
  end
end

Found this answer in the fine manual.

the fine manual

Graeme Worthy
BEAUTIFUL! I struggled with this for hours!! thanks :)
A: 

I've got the same problem. I've read all the docs and tutortials and can't seem to get around it. I've also tried adding all the authlogic columns and changing the size limit on the various restful auth columns vs just trying the DB "as-is" but changing the code to use authlogic and the following setting:

acts_as_authentic do |c| c.act_like_restful_authentication = true end

I just always get "Password is not valid" preventing the user_session from being saved. I'm guessing it's to do with the crypto routines but there shouldn't have been anything non-standard about the way we were using restful-authentication.

When I add the required columns and take out the "act_link_restful_authentication = true" it works fine (the straight up default authlogic).

Has anyone got any more ideas as to what might be wrong?