Yii2 - 页面未正确重定向

时间:2015-10-24 05:55:32

标签: yii2 yii2-advanced-app

2015-10-24 03:06:08.749683[vagrant1] Copying file...
2015-10-24 03:06:08.751826[basement] Copying file...
2015-10-24 03:06:08.757040[upstairs] Copying file...
2015-10-24 03:06:16.222416[vagrant1] Copy complete.
2015-10-24 03:06:18.094373[upstairs] Copy complete.
2015-10-24 03:06:22.478711[basement] Copy complete.

上面的代码是siteController.php的行为。当我以前登录时显示"页面没有正确重定向"。

SiteController.php

public function behaviors()
{
    return [
        'access' => [
            'class' => AccessControl::className(),
            'only' => ['login','error','index', 'logout','addhotels'],
            'rules' => [
                [
                    'allow' => true,
                    'actions' => ['index', 'logout','addhotels'],
                    'roles' => ['@'],
                ],
                [
                    'allow' => true,
                    'actions' => ['login','error'],
                    'roles' => ['?'],
                ],
            ],
        ],
        'verbs' => [
            'class' => VerbFilter::className(),
            'actions' => [
                'logout' => ['post'],
            ],
        ],
    ];
}

AdminLoginForm.php

public function actionLogin()
    {
        if (!\Yii::$app->user->isGuest) {
            return $this->goHome();
        }

        $model = new AdminLoginForm();
        if ($model->load(Yii::$app->request->post()) && $model->login()) {
            return $this->redirect(array('index'));
        } else {
            $this->layout = '//loginLayout';
            return $this->render('login', [
                'model' => $model,
            ]);
        }
    }

这里我发布了SiteController.php和AdminLoginForm.php代码。也许RBAC会帮助我吗?我更新了我的测试版yii2.0。与AccessRoles有什么关系吗?

0 个答案:

没有答案