Here is another somewhat way to do it.

Your real password field is called: passwd
In your form, place a field called: new_password

Now call these lines in your controller:

$this->data['User']['new_password_hash'] = $this->Auth-
>password( $this->data['User']['new_password']);
$this->User->save( $this->data );

Now in your User model put this in your beforeSave()

$this->data['User']['passwd'] = $this->data['User']
['new_password_hash'];

Make your validation rules applicable to the field 'new_password'
field, a value that will never be hashed.  If those validation rules
pass, then pass on that hashed version of new_password which is stored
in new_password_hash.


On Jan 17, 8:03 am, dizz <[EMAIL PROTECTED]> wrote:
> Thanks to both of you, I thought of this, but I thought it would be
> easier to disable the AuthComponent::hashPasswords and then do what
> Baz did above.
>
> Anyways thanks again for the help.
>
> -Andrew
>
> On Jan 17, 10:45 pm, Baz <[EMAIL PROTECTED]> wrote:
>
> > Yep,
>
> > Use a different field, eg. new_password or something. (I'm assuming
> > you're validating when creating a password. No need for login)
>
> > Here's assuming you have a model called User:
>
> > // needed for validation for some reason
> > $this->User->set($this->data);
> > if ($this->validates($this->data))
> > {
> >     $this->data['User']['passwd'] =
> > $this->Auth->password($this->data['User']['new_passwd'] )
>
> >     // all we did was hash passwords, no need to revalidate.
> >     if ($this->save($this->data, false))
> >     {
> >         //    do stuff
> >     } else
> >     {
> >         // invalid
> >     }
>
> > }
>
> > Would be nice to stick this is beforeSave in the model, but you can't
> > [easily] access the Auth component from the model.
>
> > Hope this helps.
>
> > On Jan 17, 2008 9:31 AM, dizz <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
>
> > > I am using the auth component and before my model can validate the
> > > password the auth component already encrypts the password so making it
> > > impossible to use the between built in valid method.
>
> >
> Is there any work around for this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to