本文整理汇总了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);
}