本文整理汇总了PHP中Cake\ORM\Table::resetPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::resetPassword方法的具体用法?PHP Table::resetPassword怎么用?PHP Table::resetPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\Table
的用法示例。
在下文中一共展示了Table::resetPassword方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resetPassword
/**
* Allows the user to enter a new password.
*
* @param string $token
* @param array $options
* @return void
*/
public function resetPassword($token = null, $options = [])
{
$options = Hash::merge($this->_defaultConfig['resetPassword'], $options);
if (!empty($this->request->query[$options['queryParam']])) {
$token = $this->request->query[$options['queryParam']];
}
try {
$entity = $this->UserTable->verifyPasswordResetToken($token, $options['tokenOptions']);
} catch (RecordNotFoundException $e) {
if (empty($this->_config['resetPassword']['invalidErrorMessage'])) {
$this->_config['resetPassword']['invalidErrorMessage'] = $e->getMessage();
}
$this->handleFlashAndRedirect('invalidError', $options);
$entity = $this->UserTable->newEntity();
}
if (isset($entity->token_is_expired) && $entity->token_is_expired === true) {
if (empty($this->_config['resetPassword']['invalidErrorMessage'])) {
$this->_config['resetPassword']['invalidErrorMessage'] = $e->getMessage();
}
$this->handleFlashAndRedirect('expiredError', $options);
}
if ($this->request->is('post')) {
$entity = $this->UserTable->patchEntity($entity, $this->request->data);
if ($this->UserTable->resetPassword($entity)) {
$this->handleFlashAndRedirect('success', $options);
} else {
$this->handleFlashAndRedirect('error', $options);
}
} else {
$entity = $this->UserTable->newEntity();
}
$this->_controller->set('entity', $entity);
}