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