i try to send email after registration with authkey attribute. But i have problem with this authkey from user. I dont know why it not save this before send this email. There is my code from SignupForm:
public function getSetPasswordLink() {
$user = User::findOne([
'status' => User::STATUS_DELETED,
'email' => $this->email,
]);
var_dump($user['auth_key']);
exit();
return Url::to(['registration/confirm', 'email' => $this->email, 'authkey' => $user['auth_key']], true);
}
public function sendEmail() {
$status = Yii::$app->mailer->compose('registrationmail',['url' => $this->getSetPasswordLink()])
->setTo($this->email)
->setCharset('utf8')
->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->params['supportEmail']])
->setSubject(self::SUBJECT)
->send();
return $status;
}
There is my function sendEmail with url which i try to pass to the view. This var_dum return me NUll. MAybe i show my action Confirm in my RegistrationController:
public function actionConfirm($email, $key) {
$user = \common\models\User::find()->where([
'email' => $email,
'auth_key' => $key,
'status' => 0,
])->one();
if (!empty($user)) {
$user->status = 10;
$user->save();
Yii::$app->getSession()->setFlash('success', 'Success!');
} else {
Yii::$app->getSession()->setFlash('warning', 'Failed!');
}
return $this->goHome();
}
So i send email and in this email i pass url to my actionConfirm. If user click this link his status become 1 instead of 0. But I dont know why my auth_key is return me NULL. Anyone can see my fail?