Authlogic Password confirmation is too short Error. NEED HELP

Hi:

I am using authlogic, and following railscast tutorial. I am running
into this error code with the password confirmation.

authlogic password confirmation is too short

Has anyone experienced this error? I need your help.

Thanks in advance for your help.

about2flip wrote:

Hi:

I am using authlogic, and following railscast tutorial. I am running
into this error code with the password confirmation.

authlogic password confirmation is too short

Has anyone experienced this error? I need your help.

Thanks in advance for your help.

Configure Authlogic with a different minimum password length (check the
rdoc for details).

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Hi:

I read through the rdocs, and I saw the following:

def require_password_confirmation(value = nil)
rw_config(:require_password_confirmation, value, true)
end

def validates_length_of_password_field_options(value = nil)
rw_config(:validates_length_of_password_field_options, value,
{:minimum => 4, :if => :require_password?})
end

def validates_length_of_password_confirmation_field_options(value =
nil)
rw_config(:validates_length_of_password_confirmation_field_options,
value, validates_length_of_password_field_options)
end

i put these into my ApplicationController, and it does not seem to be
working. It still tells me that my password confirmation is too short.
I am pulling out my hair.

Any help would be greatly appreciated. Also, I am on XP OS.

Thanks Again

On Oct 27, 8:39 am, Marnen Laibow-Koser <rails-mailing-l…@andreas-

On Tue, Oct 27, 2009 at 8:28 AM, about2flip [email protected] wrote:

It still tells me that my password confirmation is too short.

Then that’s probably because it’s zero-length because you’re not
actually passing anything. Typo in login form, maybe?

Have you put any debugging statements in your controller to show
the value for password confirmation that you think you’re using?


Hassan S. ------------------------ [email protected]
twitter: @hassan

I don’t require max 4. It is doing it automatically, which is why I am
getting pissed off. I don’t have anything set stating that max is 4.

On Oct 27, 2009, at 8:28 AM, about2flip wrote:

rw_config(:validates_length_of_password_field_options, value,
working. It still tells me that my password confirmation is too short.
I am pulling out my hair.

These don’t go in your ApplicationController… they go into the model
that you are applying AuthLogic on. The below would change the
minimum to 1 character.

class User < ActiveRecord::Base
acts_as_authentic do |c|

c
.merge_validates_length_of_password_confirmation_field_options
:minimum => 1
end
end

Unless you have a good reason though requiring at least 4 characters
isn’t unreasonable (some would argue you should require more).

-philip

about2flip wrote:

I don’t require max 4. It is doing it automatically, which is why I am
getting pissed off. I don’t have anything set stating that max is 4.

Right, because Authlogic sets sensible defaults. Just override them as
outlined above if you don’t like them. Nothing to get pissed off about.

about2flip wrote:

I tried what you suggested, and now it’s telling me that password is
too short minimum 1. I am putting in 4,5,6 characters. I also put in
this:

merge_validates_confirmation_of_password_field_options

What are the options, I don’t see them in rdoc.

They’re in the rdoc. Check out the various
ActsAsAuthentic::[whatever]::Config modules.

Thanks.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

This is what I am seeing when I submit:

Processing UsersController#create (for 127.0.0.1 at 2009-10-27
13:02:52) [POST]
Parameters: {“user”=>{“password_confirmation”=>“1234”,
“username”=>“about2flip
“, “password”=>“1234”, “email”=>“[email protected]”},
“commit”=>“Submit”, “authen
ticity_token”=>”+Xtj768EKeR4j+sQ7maJv+ly9wfTD02jRQq4WaJH/zc=”}
WARNING: Can’t mass-assign these protected attributes:
password_confirmation
←[4;35;1mUser Exists (0.0ms)←[0m ←[0mSELECT “users”.id FROM
“users” WHERE (L
OWER(“users”.“email”) = ‘[email protected]’) LIMIT 1←[0m
←[4;36;1mUser Exists (0.0ms)←[0m ←[0;1mSELECT “users”.id FROM
“users” WHERE
(LOWER(“users”.“username”) = ‘about2flip’) LIMIT 1←[0m
←[4;35;1mUser Exists (0.0ms)←[0m ←[0mSELECT “users”.id FROM
“users” WHERE ("
users".“persistence_token” =
‘1208ff98da888d6b012a4eb64283417acf264d4e3baf612219
1c98f05e3dbcf913691b2690dacc928a4b116f189c6c6f4d226aaaf081d2bc9b5d4fa94aabd837’)
LIMIT 1←[0m
Rendering template within layouts/application
Rendering users/new
Rendered users/_form (16.0ms)
Completed in 187ms (View: 16, DB: 0) | 200 OK [http://localhost/users]

What does this mean: WARNING: Can’t mass-assign these protected
attributes:

thanks

On Oct 27, 12:37Â pm, Marnen Laibow-Koser <rails-mailing-l…@andreas-

I tried what you suggested, and now it’s telling me that password is
too short minimum 1. I am putting in 4,5,6 characters. I also put in
this:

merge_validates_confirmation_of_password_field_options

What are the options, I don’t see them in rdoc.

Thanks.

On 27 Oct 2009, at 17:13, about2flip wrote:

Would it be because of this line in my model:

attr_accessible :username, :email, :password

yes - this means that

User.create(params[:user]) won’t set username, email or password.

Fred

Well I think I fixed it because I see my data saved to the DB table. I
just added this:

attr_accessible :username, :email, :password, :password_confirmation

but I got a controller error:

undefined local variable or method `root_url’ for #<UsersController:
0x477b998>

will try to figure out.

Thanks to all that replied and helped

On Oct 27, 1:14 pm, Frederick C. [email protected]

about2flip wrote:
[…]

What does this mean: WARNING: Can’t mass-assign these protected
attributes:

thanks

Read about AR::Base.attr_protected and .attr_accessible. I think
Authlogic may make the password fields protected by default.

On Oct 27, 12:37Â pm, Marnen Laibow-Koser <rails-mailing-l…@andreas-

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Would it be because of this line in my model:

attr_accessible :username, :email, :password

thanks

On Oct 27, 12:37 pm, Marnen Laibow-Koser <rails-mailing-l…@andreas-

On 27 Oct 2009, at 17:20, about2flip wrote:

Well I think I fixed it because I see my data saved to the DB table. I
just added this:

attr_accessible :username, :email, :password, :password_confirmation

Sorry I got things the wrong way round - attr_accessible means that
User.new(params[:user]) will assign them, however when you use
attr_accessible any attribute you don’t name is implicitly made
attr_protected (which is the thing where they aren’t mass assigned).

Fred