I tried putting it outside the array validation where it gives parsing
error without the bracket sign "("On Dec 21, 9:58 pm, John Maxim <[email protected]> wrote: > Hi, thanks Amit, but > > I got an error here: > > Parse error: parse error, expecting `')'' in C:\wamp\www\cakephp\app > \models\user.php on line 66 > > On line 66 is: > > function confirmPassword() > { > return (($this->data[$this->alias]['password']) == > Security::hash($this->data[$this->alias]['confirm_password']), null, > true); > } > > I modified a few times to include and exclude some of the brackets, > but it gives the same error as shown above. *I used Amit code as > originally and it started with the error above. > > Do I add this function inside the var $validate = array ( ); > > or it has to be outside the array validation ? > > Can someone look where the function go wrong ? > > On Dec 21, 5:41 pm, Amit Badkas <[email protected]> wrote: > > > Hi, > > > You need to use custom validation method for this in your model, something > > like > > > 'confirm_password' => array( > > 'notEmpty' => array( > > 'rule' => 'notEmpty', > > 'message' => 'This field cannot be blank.', > > 'last' => true, > > ), > > 'lengthCheck' => array( > > 'rule' => '/^.{6,40}$/', > > 'message' => 'Minimum password 6 > > characters.', > > 'last' => true, > > ), > > 'confirmed' => array( > > 'rule' => 'confirmPassword' > > 'message' => 'Both passwords should match.' > > ), > > ), > > > function confirmPassword() > > { > > return ($this->data[$this->alias]['password'] == > > Security::hash($this->data[$this->alias]['confirm_password'], null, true)); > > > } > > > FYI, password hash mechanism uses Security::hash(), that's why we also need > > to hash our confirmed password for comparison. > > > Hope this helps. > > > Amit Badkas > > > PHP Applications for E-Biz:http://www.sanisoft.com > > > On Tue, Dec 21, 2010 at 2:39 PM, John Maxim <[email protected]> wrote: > > > Hi, > > > > Do you know how to match value in password with confirm_password ? I > > > tried equalTo but it is meant for fixed value ? > > > > I have tried what you suggested before this, since your first post, I > > > understand, however, the passwords matching for the 2 password fields > > > using validation--do you think it is possible without creating a > > > function ? > > > > @previous post, I was referring to the Solution 1 where it created a > > > function, I think it was put in model. > > > > Solution 2 is something what I'm trying to do half-way.... > > > > thanks for you time. > > > > On Dec 21, 4:45 pm, Amit Badkas <[email protected]> wrote: > > > > Hi, > > > > > Use name of password confirmation field instead of 'password' in > > > > validate > > > > array, something like > > > > > 'confirm_password' => array( > > > > 'notEmpty' => array( > > > > 'rule' => 'notEmpty', > > > > 'message' => 'This field cannot be > > > blank.', > > > > 'last' => true, > > > > ), > > > > 'lengthCheck' => array( > > > > 'rule' => '/^.{6,40}$/', > > > > 'message' => 'Minimum password 6 > > > > characters.', > > > > 'last' => true, > > > > ), > > > > ), > > > > > Hope this helps. > > > > > Amit Badkas > > > > > PHP Applications for E-Biz:http://www.sanisoft.com > > > > > On Tue, Dec 21, 2010 at 1:22 PM, John Maxim <[email protected]> wrote: > > > > > @Amit > > > > > First...., > > > > > > Thanks man. > > > > > > Second..., > > > > > Do you know how to implement Solution 1 above ? > > > > > > On Dec 21, 12:47 pm, Amit Badkas <[email protected]> wrote: > > > > > > Hi, > > > > > > > If your form has password confirmation field then you can add 'not > > > empty' > > > > > > and 'length check' validations for that field as it won't contain > > > hashed > > > > > > value. > > > > > > > Amit Badkas > > > > > > > PHP Applications for E-Biz:http://www.sanisoft.com > > > > > > > On Mon, Dec 20, 2010 at 10:43 PM, John Maxim <[email protected]> > > > wrote: > > > > > > > 'password' => array( > > > > > > > 'notEmpty' => array( > > > > > > > 'rule' => 'notEmpty', > > > > > > > 'message' => 'This field cannot be > > > > > blank.', > > > > > > > 'last' => true, > > > > > > > ), > > > > > > > 'lengthCheck' => array( > > > > > > > 'rule' => '/^.{6,40}$/', > > > > > > > 'message' => 'Minimum password 6 > > > > > > > characters.', > > > > > > > 'last' => true, > > > > > > > ), > > > > > > > ), > > > > > > > > ** > > > > > > > The registration validation is affected when hash password is > > > enabled. > > > > > > > It doesn't matter how the hash was enabled; using Auth component; > > > or > > > > > > > Md5, once hash is enabled, the password validation no longer can > > > > > > > be > > > > > > > triggered. So, I think something wrong with the above validation ? > > > > > > > > The full validations for all fields are below: (Note: only the > > > > > > > password validation is affected) > > > > > > > > 'username' => array( > > > > > > > 'notEmpty' => array( > > > > > > > 'rule' => 'notEmpty', > > > > > > > 'message' => 'This field cannot be > > > > > blank.', > > > > > > > 'last' => true, > > > > > > > ), > > > > > > > 'uniqueCheck' => array( > > > > > > > 'rule' => 'isUnique', > > > > > > > 'message' => 'That username has > > > already > > > > > been > > > > > > > taken.', > > > > > > > 'last' => true, > > > > > > > ), > > > > > > > 'lengthCheck' => array( > > > > > > > 'rule' => '/^.{6,40}$/', > > > > > > > 'message' => 'Minimum username 6 > > > > > > > characters.', > > > > > > > 'last' => true, > > > > > > > ), > > > > > > > ), > > > > > > > > 'email' => array( > > > > > > > 'notEmpty' => array( > > > > > > > 'rule' => 'notEmpty', > > > > > > > 'message' => 'This field cannot be blank.', > > > > > > > 'last' => true, > > > > > > > ), > > > > > > > 'email' => array( > > > > > > > 'rule' => 'email', > > > > > > > 'message' => 'That is not a valid email > > > > > > > address.', > > > > > > > 'last' => true, > > > > > > > ), > > > > > > > ), > > > > > > > > 'password' => array( > > > > > > > 'notEmpty' => array( > > > > > > > 'rule' => 'notEmpty', > > > > > > > 'message' => 'This field cannot be > > > > > blank.', > > > > > > > 'last' => true, > > > > > > > ), > > > > > > > 'lengthCheck' => array( > > > > > > > 'rule' => '/^.{6,40}$/', > > > > > > > 'message' => 'Minimum password 6 > > > > > > > characters.', > > > > > > > 'last' => true, > > > > > > > ), > > > > > > > ), > > > > > > > > ** > > > > > > > Is there an alternative way to write these validations?; I have no > > > > > > > clue why the password validation is nullified when hash password > > > > > > > is > > > > > > > enabled using any way. > > > > > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp > > > > > others > > > > > > > with their CakePHP related questions. > > > > > > > > You received this message because you are subscribed to the Google > > > > > Groups > > > > > > > "CakePHP" group. > > > > > > > To post to this group, send email to [email protected] > > > > > > > To unsubscribe from this group, send email to > > > > > > > [email protected]<cake-php%[email protected]> > > > <cake-php%[email protected]<cake-php%[email protected]> > > > > > > <cake-php%[email protected]<cake-php%[email protected]> > > > <cake-php%[email protected]<cake-php%[email protected]> > > > >>For > > > > > more options, visit this group at > > > > > > >http://groups.google.com/group/cake-php?hl=en > > > > > > Check out the new > > ... > > read more » Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
