I'm trying to to allow users to update their password should they
forget it using a "Forget Password" link which maps to method
resetPassword().  I am using the Auth component and when registering a
new user and saving the account details to the database the password
is automattically encrypted and saved properly using the register()
method.  However, in this case when resetting the password I can not
get the same encryption of password to occur.  Please advise on how i
can get this password encrypted.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
        function resetPassword($id,$phrase) {
                //  Next feature for implementation   To be debugged
                $this->User->id = $id;
                $this->data = $this->User->read();

                $this->set('phrase', $phrase);

                $createdHash = md5($this->data['User']['password'].$this-
>data['User']['created']);

        if(strcmp($phrase,$createdHash) == 0)
        {

                        
if(!empty($this->Auth->data['User']['password_confirm']))
                        {
                                        if 
($this->Auth->data['User']['password'] == $this->Auth-
>data['User']['password_confirm'])
                            {
                                        
$this->User->confirmPassword($this->data);
                                $this->User->saveField('password',$this->Auth-
>data['User']['password'],true);


                                $this->flash("Your password has been updated."  
,"/
users/login",5);
                                exit();
                            }
                            else
                            {
                                $this->flash("Your password reset failed.  
Please make
sure your passwords match."  ,"/users/resetPassword/".$id."/".$phrase,
5);
                            }
                        }
                        else
                        {
                                        $this->data['User']['password'] = "";


                        }

        }
        else
        {
                $this->data['User']['password']="";
                $this->flash("You do not have permission to reset the password
for this user.  If you think you have received this message in error
please verify the link provided in your reset request e-mail."  ,"/
users/Roda/",5);
                exit();

        }
    }



-----------------------------------------------------


function register() {
                print_r(debug($this));
        if (!empty($this->data)) {
            if ($this->User->confirmPassword($this->data)){
                $this->User->create();
                if($this->User->save($this->data))//;
                {
                        $this->_sendRegistrantConfirmationMail($this-
>data['User']['username']);
                        $this->flash("Thank you for registering.  You must
verify your registration in order to login to your account.  An email
verificaiton has been sent your email at ". $this->data['User']
['username'],"/users/login",5);
                }
            }
        }
        $this->data['User']['password']='';
        $this->data['User']['password_confirm']='';
    }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to