Commit 51fcd1b7 by Teeradone-PIM

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

parent 32e0c1de
......@@ -117,13 +117,12 @@ class UsersController extends AppController {
'keyField' => 'id',
'valueField' => 'province_name_th'
]
);
);
if(!empty($provinces)) $provinces = $provinces->toArray();
$this->set(compact('provinces','countries'));
$this->viewBuilder()->layout('blank');
}
$this->viewBuilder()->layout('blank');
}
#---------------------------------------------------------------------------------------------------
#Signup
......@@ -405,31 +404,49 @@ class UsersController extends AppController {
$confirm_password = $this->request->data['confirm_password'];
$this->request->data['password'] = $hasher->hash($this->request->data['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());
$this->Users->save($users);
$this->Flash->success(__('change password success'));
return $this->redirect(['action' => 'signin']);
}
$this->set(array('token' => $token, '_serialize' => array('token')));
}
#---------------------------------------------------------------------------------------------------
/**
*
* Function user logout / signout
* @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());
}
public function signout()
{
$this->checkToken();
}
......
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