I am new to Cake but, am diving in head first... I've tried several
different types of coding examples on how to allow a User to change
their password. This is the version I am trying and we (my group) do
have Auth working, so 'User' needs to be "Auth.User" ... Can anyone
give me an idea why it doesn't work?
function change_password() {
if (!empty($this->data)) {
$user = $this->Session->read("Auth.User");
$this->User->id = $user['id'];
$someone = $this->User->findById($this->User->id);
if(md5($this->data['change']['oldpassword']) !=
$someone["Auth.User"]['password']) {
$this->User->invalidate('oldpassword', 'Your
old password is invalid');
}
if($this->data['change']['newpassword'] !=this-
>data['change']['confirmpassword']){
$this->User->invalidate('newpassword', 'Your
passwords do not match');
$this->User->invalidate('confirmpassword',
'Your passwords do not match');
} else {
$encryptedPassword = md5($this->data['change']
['newpassword']);
$this->data["Auth.User"]['password'] =
$encryptedPassword;
$this->data["Auth.User"]['id'] = $this->User-
>id;
}
if ($this->User->save($this->data)){
$this->flash('Password updated, please login
again.','/users/logout');
} else {
$this->render();
}
}
}
Thanks in advance,
Ed
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php