Yii2: Signup page shows error “403 forbidden you are not allowed to access the page”

北战南征 提交于 2019-12-24 11:04:43

问题


I have my signup controller code.

public function actionSignup()
{
    $model = new SignupForm();
    if ($model->load(Yii::$app->request->post()) && $model->validate()) {
        if ($user = $model->signup()) {
            $this->layout = 'index';
                return $this->goHome();
        }
    }
    $this->layout = 'index';
    return $this->render('signup', [
        'model' => $model,
    ]);
}

When i, through url pass the address as index.php?r=site/login then there appears login form & that works fine. But when i pass as index.php?r=site/signup then it shows me above error. I am not getting this....


回答1:


Signup action is for guests, you get this 403 error because you are already authenticated.



来源:https://stackoverflow.com/questions/27380297/yii2-signup-page-shows-error-403-forbidden-you-are-not-allowed-to-access-the-p

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!