本文整理匯總了PHP中Cake\ORM\Table::changePassword方法的典型用法代碼示例。如果您正苦於以下問題:PHP Table::changePassword方法的具體用法?PHP Table::changePassword怎麽用?PHP Table::changePassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\ORM\Table
的用法示例。
在下文中一共展示了Table::changePassword方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: changePassword
/**
* Let the logged in user change his password.
*
* @param array $options
* @return void
*/
public function changePassword($options = [])
{
$options = Hash::merge($this->_defaultConfig['changePassword'], $options);
$entity = $this->UserTable->newEntity();
$entity->accessible(['id', 'old_password', 'new_password', 'confirm_password'], true);
if ($this->request->is(['post', 'put'])) {
$entity = $this->UserTable->patchEntity($entity, $this->request->data);
$entity->id = $this->_controller->Auth->user('id');
$entity->isNew(false);
if ($this->UserTable->changePassword($entity)) {
$this->request->data = [];
$entity = $this->UserTable->newEntity();
$entity->id = $this->_controller->Auth->user('id');
$entity->isNew(false);
$this->handleFlashAndRedirect('success', $options);
} else {
$this->handleFlashAndRedirect('error', $options);
}
}
$this->_controller->set('entity', $entity);
}