From d21c9d78c2ff701f7aef76af0b2c79c8fa519797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Sun, 11 May 2014 15:22:27 +0200 Subject: [PATCH] password --- app/Controller/RegistrationController.php | 3 +-- app/Model/User.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) 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();