Validating passwords

Hey people,

I was wondering how to solve the following problem…

I have a login system which uses MD5 + salts to store my users passwords
in the database. Also I am working with profiles for my users which they
can change.

Everything goes quite okay except when we reach the change_profile bit
of the application. Because the user model has validations it performs
on the password it starts throwing error when a user views the
change_profile page. The errors are there as soon as the page is loaded,
even before the form gets submitted.

3 errors prohibited this candidate from being saved

There were problems with the following fields:

* Password confirmation can't be blank
* Password can't be blank
* Password is too short (minimum is 4 characters)

Is there a way to stop the model from using it’s password validations
whenever a user is changing his profile? I tried to exclude the password
fields from the change_profile form, but this still generates the same
errors…

Thanks in advance,

Danny

Hi Danny,

Daniel Owen van Dommelen wrote:

Because the user model has validations it performs
on the password it starts throwing error when a user
views the change_profile page. The errors are there
as soon as the page is loaded, even before the form
gets submitted.

3 errors prohibited this candidate from being saved

Is there a way to stop the model from using it’s password
validations whenever a user is changing his profile?

Sorry to be dense, but I’m not getting a clear picture here and need to
ask
a couple of questions. Is the password stored in the User model? Is
the
profile part of the User model? Validations get run on three events:
create, update, and save. You must be doing one of those to get the
errors
you’re getting. Which doesn’t make sense given your description of the
situation. Or maybe I just haven’t gotten enough caffine into the
system
yet :wink: At any rate, you can specify which event(s) trigger the
validation(s) in your validate methods. Check the
ActiveRecord::Validations::ClassMethods documentation at
http://api.rubyonrails.org/

hth,
Bill

Bill W. wrote:

Hi Danny,

Daniel Owen van Dommelen wrote:

Because the user model has validations it performs
on the password it starts throwing error when a user
views the change_profile page. The errors are there
as soon as the page is loaded, even before the form
gets submitted.

3 errors prohibited this candidate from being saved

Is there a way to stop the model from using it’s password
validations whenever a user is changing his profile?

Sorry to be dense, but I’m not getting a clear picture here and need to
ask
a couple of questions. Is the password stored in the User model? Is
the
profile part of the User model? Validations get run on three events:
create, update, and save. You must be doing one of those to get the
errors
you’re getting. Which doesn’t make sense given your description of the
situation. Or maybe I just haven’t gotten enough caffine into the
system
yet :wink: At any rate, you can specify which event(s) trigger the
validation(s) in your validate methods. Check the
ActiveRecord::Validations::ClassMethods documentation at
http://api.rubyonrails.org/

hth,
Bill

Hey, thanks for replying… I believe one of the members on our team has
already resolved the problem. The problem was pretty complex and at the
moment I just do not have the time to completely detail it for you…
Anyways, thanks again for replying, you’ll probably see me back here :wink:

Ow and about the coffee, I guess that must be one of the reasons for
basically everything, goigng to “the machine” right now myself…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs