Re: Validating Password: Newbie Question

2007-11-25 Thread Sergei
Just a note 'password' => VALID_NOT_EMPTY, is wrong. You need something like: 'password' => '/^[a-z0-9]{6,30}$/i', that means minimum 6 symbols, maximum 30, only letters and digits. On Nov 26, 2:22 am, oracle411 <[EMAIL PROTECTED]> wrote: > 'password' =>

Re: Validating Password: Newbie Question

2007-11-25 Thread majna
Some Snipp for user model: function beforeValidate() { if ( isset($this->data[$this->name]['password']) && isset($this- >data[$this->name]['password2']) ) { # invalidate empty password2 if ( empty($thi

Validating Password: Newbie Question

2007-11-25 Thread oracle411
I want users to enter their password twice to validate it, and I do so with the code below. But it seems that I need to have two field in my DB table in order to have this work (password and confirm_password). Since I only will use the confirm_password field once, I rather not store it in my DB.

Re: validating password

2007-06-30 Thread Dr. Tarique Sani
On 6/30/07, Geoff Ford <[EMAIL PROTECTED]> wrote: > > > actual hex or numeric codes doesn't matter, and then the view and > __() would format/translate them to the needed display. I rest my case Thanks you validated my POV :) Tarique ==

Re: validating password

2007-06-30 Thread Geoff Ford
I realize that there are situtations where different output is required, but again this is a formatting issue. In these situations you would use error codes, whether they are the english default or actual hex or numeric codes doesn't matter, and then the view and __() would format/translate them

Re: validating password

2007-06-29 Thread Dr. Tarique Sani
On 6/30/07, Geoff Ford <[EMAIL PROTECTED]> wrote: > > > Yes, you just remove the error index in the view. > > And I disagree, Tarique, error message should be _generated_ by the > model, as it is related to the value of the data. Well the same model can have several kind of views so What if your

Re: validating password

2007-06-29 Thread Geoff Ford
Yes, you just remove the error index in the view. And I disagree, Tarique, error message should be _generated_ by the model, as it is related to the value of the data. The _formatting_ of the error message should most definately be handled in the view. On Jun 29, 5:03 pm, "[EMAIL PROTECTED]" <[

Re: validating password

2007-06-29 Thread [EMAIL PROTECTED]
Do you have any examples of how this is accomplished? Do i just remove the error index from the array in the view.. And tarique, i think to me it seems a matter of opinion whether you have errors in the view or the model.. Personally i'd rather have them in the model but i'm sure many people would

Re: validating password

2007-06-28 Thread Dr. Tarique Sani
On 6/29/07, Geoff Ford <[EMAIL PROTECTED]> wrote: > Either way you shouldn't set the error message in the view, it should > be pulled from the models validationErrors I would like to add a small amendment to the above - You need not set the error message in the view, it can be pulled from the mo

Re: validating password

2007-06-28 Thread Geoff Ford
In 1.2 $form->input() automatically picks up the error message and you don't need to set error in the view. In 1.1 I think you need to use $html->errorTag() or something like that. Either way you shouldn't set the error message in the view, it should be pulled from the models validationErrors O

Re: validating password

2007-06-27 Thread [EMAIL PROTECTED]
If i use $this->invalidate("password", "Passwords do not match"); how do i associate that in my view.. Currently my view has input('password', array('error' => 'Password must be at least 4 characters.', 'type'=>'password',

Re: validating password

2007-06-27 Thread Geoff Ford
it the lines function beforeSave() { if ($this->validates()) { that Grant was talking about; $this->validates(); is called automatically before it beforeSave() gets called so your call to $this->validates() is redundant. On Jun 28, 12:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED

Re: validating password

2007-06-27 Thread [EMAIL PROTECTED]
That is a good idea about using invalidate. I didnt know i could do it that way. And i'm not sure which code you are referring to, but the latest post with code that i posted i did not call beforeValidate on my own.. Maybe you read that part wrong.. Those were separate functions.. Second of all, i

Re: validating password

2007-06-27 Thread Grant Cox
I would use $this->invalidate('password', "Passwords do not match") - this way it is just the same as any other validation routine. You also don't need to call beforeValidate() in your beforeSave, it is done automatically by Cake when you save. Your beforeSave is still MD5-ing every password tha

Re: validating password

2007-06-27 Thread [EMAIL PROTECTED]
Ok i got it all working now, unsetting the field did work here is what i did in my model: function beforeValidate() { $u = &$this->data['User']; $p1 = &$u['password']; $p2 = &$u['password1']; if ($p1 !

Re: validating password

2007-06-27 Thread [EMAIL PROTECTED]
Ok this is what i've added and its not working. beforeSave never gets called.. I tested by putting a die statement at the top. Users controller: function edit_profile() { $this->User->id = $this->Session->read('User.id'); if (empty($this->data)) {

Re: validating password

2007-06-27 Thread [EMAIL PROTECTED]
Good idea grant.. I was wondering how to figure that out.. I'm a bit unsure what you mean though about having a hashed_password field? I don't want to put the hashed password into a hidden input in the form (md5 is known for dictionary attacks, and although this site i'm sure would never have that

Re: validating password

2007-06-27 Thread Grant Cox
Its $this->User->validates( $this->data ) , not validate. Cake has a habit of executing any unknown function you call on a model as SQL. You can still do it all in the model, just use the beforeValidate to validate the password submitted is ok (number of chars, matches confirm password etc) an

validating password

2007-06-27 Thread [EMAIL PROTECTED]
I have an edit profile form where the user can enter password and password1 box if they want it to change.. In my model i have a regex for a valid password. My passwords are md5'd and i want to be able to make sure its a valid password before doing the save.. And after i make sure it validates, i