diff --git a/app/Controller/RegistrationController.php b/app/Controller/RegistrationController.php index 35dd56c..05abd86 100644 --- a/app/Controller/RegistrationController.php +++ b/app/Controller/RegistrationController.php @@ -185,8 +185,7 @@ class RegistrationController extends AppController { if (!$send and $this->request->is('post')) { if ($this->request->data['User']['password1'] == $this->request->data['User']['password2']) { $profil['User']['password'] = $this->MiconwareSession->create_hash($this->request->data['User']['password1']); - $this->User->id=$try['User']['id']; - $result = $this->User->saveField('password',$profil['User']['password']); + $result = $this->User->replace_password($try,$profil['User']['password']); if ($result) { $this->MiconwareSession->setFlash(__('dreamjob.password_replace.done'), 'flash', array('alert' => 'success')); } else { diff --git a/app/Model/User.php b/app/Model/User.php index 041e083..54522fb 100755 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -91,6 +91,23 @@ class User extends AppModel { } return false; } + public function replace_password($data,$password){ + $dataSource = $this->getDataSource(); + $dataSource->begin(); + $this->id = $data['User']['id']; + if($result) + $result = $this->saveField('code',''); + if($result) + $result = $this->saveField('password',$password); + + if($result) { + $dataSource->commit(); + return true; + } else { + $dataSource->rollback(); + } + return false; + } public function activeLinkUser($mail,$key){ $dataSource = $this->getDataSource();