hashed automatically, the hashing happens before validation and thus
your validation rules, except for your password compare, will never
work.
http://teknoid.wordpress.com/2008/10/08/demystifying-auth-features-in-cakephp-12/
check that out should show you what to do to fix that.
For using validation from controller you must set it to the model
first
http://book.cakephp.org/view/410/Validating-Data-from-the-Controller
On Nov 30, 9:52 am, Milmar <milmarq...@gmail.com> wrote:
> I tried $this->Model->validate() in the controller, but for some
> reason, 'password' and 'password_confirm' are not being passed to the
> Model (I tried logging them in the "beforeValidate()" callback).
> Do you have some sample code where I can see how to use $this->Model-
>
> >validate() for editing the password?
>
> Thanks.
>
> On Dec 1, 1:36 am, thatsgreat2345 <thatsgreat2...@gmail.com> wrote:
>
> > You can validate from the controller using $this->Model->validate();
>
> > On Nov 30, 9:27 am, Milmar <milmarq...@gmail.com> wrote:
>
> > > I was able to solve this by first using $this->User->save($this->data)
> > > so that I can validate the fields in the model.
> > > Then switching to the "saveField" function in the Model's "beforeSave
> > > ()" callback so that the save would not affect the HABTM relations.
> > > Here's the code for "beforeSave()":
>
> > > function beforeSave() {
> > > //If operation is save and this is an edit(has ID,password,
> > > and password_confirm),
> > > // use the saveField command to save the password
> > > if(isset($this->data[$this->alias]['password']) && isset
> > > ($this->data[$this->alias]['id']) &&
> > > isset($this->data[$this->alias]['password_confirm']))
> > > {
> > > return $this->saveField('password',$this->data[$this->alias]['password']);
>
> > > }
>
> > > $this->hashPasswords(null, true);
> > > return true;
>
> > > }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment