本文整理汇总了PHP中frontend\models\User::isPasswordResetTokenValid方法的典型用法代码示例。如果您正苦于以下问题:PHP User::isPasswordResetTokenValid方法的具体用法?PHP User::isPasswordResetTokenValid怎么用?PHP User::isPasswordResetTokenValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frontend\models\User
的用法示例。
在下文中一共展示了User::isPasswordResetTokenValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendEmail
/**
* Sends an email with a link, for resetting the password.
*
* @return boolean whether the email was send
*/
public function sendEmail()
{
/* @var $user User */
$user = Member::findOne(['status' => Member::STATUS_ACTIVE, 'email' => $this->email]);
if ($user) {
if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
$user->generatePasswordResetToken();
}
if ($user->save()) {
return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
}
}
return false;
}
示例2: resetPasswordMail
public function resetPasswordMail()
{
$this->scenario = 'resetPassword';
$this->attributes = Yii::$app->request->post();
if ($this->validate()) {
$user = static::findByEmail(['email' => $this->email, 'status' => self::STATUS_ACTIVE]);
if ($user) {
if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
$user->generatePasswordResetToken();
}
// $this->db->createCommand()->update('user', [
// 'email' => $this->email,
// 'status' => User::STATUS_NOT_ACTIVE,
// 'created_at' => time(),
// ])->execute();
if ($user->save()) {
Yii::$app->session->setFlash('success', 'Спасибо! На ваш Email было отправлено письмо со ссылкой на восстановление пароля.');
\Yii::$app->mailer->compose(['text' => 'passwordResetToken-text'], ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
Yii::$app->response->redirect('/index');
}
} else {
Yii::$app->session->setFlash('error', 'Извините. У нас возникли проблемы с отправкой.');
}
} else {
print_r($this->errors);
}
}