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