Commit 51fcd1b7 by Teeradone-PIM

teeradone chage_forgotpassword: ลืมหัสผ่าน change_password: เปลี่ยนรหัสผ่าน

parent 32e0c1de
...@@ -123,7 +123,6 @@ class UsersController extends AppController { ...@@ -123,7 +123,6 @@ class UsersController extends AppController {
$this->viewBuilder()->layout('blank'); $this->viewBuilder()->layout('blank');
} }
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
#Signup #Signup
...@@ -405,6 +404,33 @@ class UsersController extends AppController { ...@@ -405,6 +404,33 @@ class UsersController extends AppController {
$confirm_password = $this->request->data['confirm_password']; $confirm_password = $this->request->data['confirm_password'];
$this->request->data['password'] = $hasher->hash($this->request->data['password']); $this->request->data['password'] = $hasher->hash($this->request->data['password']);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)--------------------------- //------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
if (password_verify($oldpassword, $users['password'])) {
$users = $this->Users->patchEntity($users, $this->request->getData());
$this->Users->save($users);
$this->Flash->success(__('change password success'));
return $this->redirect(['action' => 'signin']);
} else {
$this->Flash->error(__('Invalid password.'));
return $this->redirect(['action' => 'change-password/'.$token]);
}
}
$this->set(array('token' => $token, '_serialize' => array('token')));
}
public function change_forgotpassword($token=null)
{
$this->viewBuilder()->layout('blank');
$users = $this->Users->find('all',[
'conditions' => [
'Users.token' => $token
]
])->first();
if ($this->request->is('post')) {
$hasher = new DefaultPasswordHasher();
$password = $this->request->data['password'];
$confirm_password = $this->request->data['confirm_password'];
$this->request->data['password'] = $hasher->hash($this->request->data['password']);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
$users = $this->Users->patchEntity($users, $this->request->getData()); $users = $this->Users->patchEntity($users, $this->request->getData());
$this->Users->save($users); $this->Users->save($users);
$this->Flash->success(__('change password success')); $this->Flash->success(__('change password success'));
...@@ -413,23 +439,14 @@ class UsersController extends AppController { ...@@ -413,23 +439,14 @@ class UsersController extends AppController {
$this->set(array('token' => $token, '_serialize' => array('token'))); $this->set(array('token' => $token, '_serialize' => array('token')));
} }
#--------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------
/** public function signout()
* {
* Function user logout / signout $this->checkToken();
* @author sarawutt.b
* @since 2018/05/22 16:44:20
* @license PAKGON
* @return void
*/
public function signout() {
$http = new Client();
$result = $http->delete(Configure::read('OAUTH2_PROVIDER.TOKEN_DETETE') . '/' . $this->Auth->user('id'))->body();
$this->Flash->success(__('You are now logged out.'));
return $this->redirect($this->Auth->logout());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment