Here is the controller function

Maybe someone can see where I am going wrong?

function changePassword() {
          $id = $this->Auth->user('id');

          $this->User->unbindValidation('keep', array('password',
'confirm'), true);
          if (!empty($this->data)) {

                  $this->data['User']['confirm'] =
$this->Auth->password($this->data['User']['confirm']);
              //debug confirm and get gf456dg5rtert132erwr string
              $this->User->set($this->data);
              if ($this->User->validates()) {
                        $this->User->id = $id;
                        $white = array('password');
                        $this->User->save($this->data, true,
array_intersect(array_keys($this->User->schema()), $white));
                  $this->Session->setFlash(__('Passwords Matched and saved',
true));
                  
              } else {
                  $this->Session->setFlash(__('Passwords Do not Match',
true));
                           $this->data = null;
              }
          }
}

User Model
Validation rules:

...
'password' => array(
                        'pass-notempty' => array(
                                'rule' => array('notempty'),
                                'required' => true,
                                'allowEmpty' => false,
                                'message' => 'Password cannot be empty.',
                                'last' => true),
                        
                        'pass-length' => array(
                                'rule' => array('minLength', 8),
                                'message' => 'Password must be minimim 8
characters.',
                                'last' => true),
        

                        'pass-Similar' => array(
                                'rule' => 'checkPasswords',
                                'message' => 'Different password entered.',
                                'last' => true)
                        ),
                
                        
                'confirm' => array(
                        'confirm-notempty' => array(
                                'rule' => array('notempty'),
                                'required' => true,
                                'allowEmpty' => false,
                                'message' => 'Pleae confirm your password.')
                        ),

...


function checkPasswords() 
        {
                  if($this->data['User']['password'] ==
$this->data['User']['confirm']) 
                {
                          // Passwords match
                          return true;
                }
        }

-----Original Message-----
From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com] 
Sent: September-29-09 3:46 PM
To: cake-php@googlegroups.com
Subject: RE: Change Password


 
Ok cool will give it a try.

Dave
-----Original Message-----
From: Miles J [mailto:mileswjohn...@gmail.com]
Sent: September-29-09 3:40 PM
To: CakePHP
Subject: Re: Change Password


I dont think hash() adds the security salt, you must use Auth->password ().




--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to