Reputation: 105
The challenge is to redirect users after registration on the login form. Whatever the conflict, it is necessary to logout after signup. Trying to use this code in controller, but it does not work
public function actionSignup()
{
$model = new SignupForm();
if ($model->load(Yii::$app->request->post())) {
if ($user = $model->signup()) {
Yii::$app->user->logout();
if (Yii::$app->getUser()->login($user)) {
return $this->goHome();
}
}
}
return $this->render('signup', [
'model' => $model,
]);
}
Upvotes: 1
Views: 876
Reputation: 996
siteController.php
public function actionSignup()
{
$model = new SignupForm();
if ($model->load(Yii::$app->request->post())) {
if ($user = $model->signup()) {
return $this->goHome();
}
}
Try this i hope this will help you..Thank You
Upvotes: 1