本文整理汇总了PHP中common\models\User::findByPasswordResetToken方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findByPasswordResetToken方法的具体用法?PHP User::findByPasswordResetToken怎么用?PHP User::findByPasswordResetToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\User
的用法示例。
在下文中一共展示了User::findByPasswordResetToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates a form model given a token.
*
* @param string $token
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws \yii\base\InvalidParamException if token is empty or not valid
*/
public function __construct($token, $config = [])
{
if (empty($token) || !is_string($token)) {
throw new InvalidParamException('Password reset token cannot be blank.');
}
$this->user = User::findByPasswordResetToken($token);
if (!$this->user) {
throw new InvalidParamException('Wrong password reset token.');
}
parent::__construct($config);
}
示例2: __construct
/**
* Creates a form model given a token.
*
* @param string $token
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws \yii\base\InvalidParamException if token is empty or not valid
*/
public function __construct($token, $config = [])
{
if (empty($token) || !is_string($token)) {
throw new InvalidParamException('Sem Token de redefinição de palavra passe.');
}
$this->_user = User::findByPasswordResetToken($token);
if (!$this->_user) {
throw new InvalidParamException('Token de redefinição de palavra passe errado.');
}
parent::__construct($config);
}
示例3: __construct
/**
* Creates a form model given a token.
*
* @param string $token
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws \yii\base\InvalidParamException if token is empty or not valid
*/
public function __construct($token, $config = [])
{
if (empty($token) || !is_string($token)) {
throw new InvalidParamException(Yii::t('app', 'PASSWORD_TOKEN_CAN_BELANK'));
}
$this->_user = User::findByPasswordResetToken($token);
if (!$this->_user) {
throw new InvalidParamException(Yii::t('app', 'WRONG_PASSWORD_TOKEN'));
}
parent::__construct($config);
}
示例4: __construct
public function __construct($token, $config = [])
{
if (empty($token) || !is_string($token)) {
throw new InvalidParamException('Password reset token cannot be blank.');
}
$this->_user = User::findByPasswordResetToken($token);
if (!$this->_user) {
//throw new InvalidParamException('Wrong password reset token.');
throw new \yii\web\BadRequestHttpException('Password reset link is expired or invalid.');
}
parent::__construct($config);
}
示例5: actionResetPassword
public function actionResetPassword($token)
{
try {
$model = new ResetPasswordForm($token);
} catch (InvalidParamException $e) {
Yii::$app->getSession()->setFlash('danger', ['type' => 'danger', 'duration' => 5000, 'icon' => 'glyphicon glyphicon-exclamation-sign', 'message' => 'Parámetro inválido', 'title' => 'Reestablecer contraseña', 'positonY' => 'top', 'positonX' => 'center']);
return $this->goHome();
//throw new BadRequestHttpException($e->getMessage()); al mostrar el error lo hace en el layout main en vez de landing
}
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
Yii::$app->getSession()->setFlash('success', ['type' => 'success', 'duration' => 5000, 'icon' => 'glyphicon glyphicon-user', 'message' => 'La contraseña se ha guardado con éxito.', 'title' => 'Reestablecer contraseña', 'positonY' => 'top', 'positonX' => 'center']);
return $this->goHome();
}
$user = User::findByPasswordResetToken($token);
if (!$user) {
throw new InvalidParamException('Wrong password reset token.');
}
return $this->renderAjax('resetPassword', ['model' => $model, 'user' => $user]);
}