Answer the question
In order to leave comments, you need to log in
Why is the user not authenticated after registering in yii2?
Good afternoon
There is an almost standard action for user registration.
After saving the user, I want to authenticate it. But authentication doesn't work.
if (!Yii::$app->user->isGuest) {
return $this->redirect(['/order/client']);
}
$model = new SignupForm();
if ($model->load(Yii::$app->request->post())) {
if ($user = $model->signup()) {
Yii::$app->user->login($user);
Yii::$app->getSession()->setFlash('success', 'Confirm you email address');
$redirectUrl = Yii::$app->request->get('redirect');
if ($redirectUrl) {
return $this->redirect(urldecode($redirectUrl));
}
return $this->refresh();
}
}
return $this->render('signup', [
'model' => $model,
]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question