Search code examples
ruby-on-railsrubypasswordsauthlogic

Authlogic incorrect password validation errors


I am getting this issue on my ubuntu 14.04 I have rails 4.1.8 and ruby 2.1.2. Last time I have tried it on mac OSX 10.10 with the same rails and ruby versions I was able to create user successfully. But when I am trying it on my ubuntu 14.04 I am getting the following errors for password field:

Password is too short (minimum is 5 characters) Password confirmation doesn't match Password

It doesn't matter what is the length of the password and I am sure that the password and password confirmation are the same thing. It seems like the authlogic does not recognize my password field. Here is my config:

acts_as_authentic do |c|
c.validates_length_of_password_field_options = {minimum: 5}
c.crypto_provider = Authlogic::CryptoProviders::BCrypt
c.login_field = :email

Note: Also authlogic recognize my email field as login_field so I don't have any issues with login field only with password and password confirmation. My password field's name in DB is :crypted_password.

Can any body please help me with this strange issue or can anybody tell me how I can debug it to see why authlogic validation fails for passord?


Solution

  • I have fixed this issue. My form was like this:

      <div class="form-group">
        <%= f.label :crypted_password, 'Password' %><br>
        <%= f.password_field :crypted_password, class: 'form-control' %>
      </div>
    

    And the my user parameters in controller were like this:

    params.require(:user).permit(:email, :crypted_password, :password_confirmation )
    

    And it seems like that the authlogic did not recognize the crypted_password parameter as password. And when I removed the "crypted" from :crypted_password it worked. I have no clue why it worked on Mac OSX but now it works on my ubuntu 14.04.