diff --git a/apps/advanced/backend/controllers/SiteController.php b/apps/advanced/backend/controllers/SiteController.php index a21f33a9b4..6850fe9a68 100644 --- a/apps/advanced/backend/controllers/SiteController.php +++ b/apps/advanced/backend/controllers/SiteController.php @@ -15,14 +15,9 @@ class SiteController extends Controller 'class' => \yii\web\AccessControl::className(), 'rules' => [ [ - 'actions' => ['error'], + 'actions' => ['login', 'error'], 'allow' => true, ], - [ - 'actions' => ['login'], - 'allow' => true, - 'roles' => ['?'], - ], [ 'actions' => ['logout', 'index'], 'allow' => true, @@ -49,6 +44,10 @@ class SiteController extends Controller public function actionLogin() { + if (!\Yii::$app->user->isGuest) { + $this->goHome(); + } + $model = new LoginForm(); if ($model->load($_POST) && $model->login()) { return $this->goHome(); diff --git a/apps/advanced/frontend/controllers/SiteController.php b/apps/advanced/frontend/controllers/SiteController.php index 26aa300d49..ae41744ac6 100644 --- a/apps/advanced/frontend/controllers/SiteController.php +++ b/apps/advanced/frontend/controllers/SiteController.php @@ -17,10 +17,10 @@ class SiteController extends Controller return [ 'access' => [ 'class' => \yii\web\AccessControl::className(), - 'only' => ['login', 'logout', 'signup'], + 'only' => ['logout', 'signup'], 'rules' => [ [ - 'actions' => ['login', 'signup'], + 'actions' => ['signup'], 'allow' => true, 'roles' => ['?'], ], @@ -54,6 +54,10 @@ class SiteController extends Controller public function actionLogin() { + if (!\Yii::$app->user->isGuest) { + $this->goHome(); + } + $model = new LoginForm(); if ($model->load($_POST) && $model->login()) { return $this->goHome(); diff --git a/apps/basic/controllers/SiteController.php b/apps/basic/controllers/SiteController.php index f369e3be6b..e3ca29b5ca 100644 --- a/apps/basic/controllers/SiteController.php +++ b/apps/basic/controllers/SiteController.php @@ -16,13 +16,8 @@ class SiteController extends Controller return [ 'access' => [ 'class' => AccessControl::className(), - 'only' => ['login', 'logout'], + 'only' => ['logout'], 'rules' => [ - [ - 'actions' => ['login'], - 'allow' => true, - 'roles' => ['?'], - ], [ 'actions' => ['logout'], 'allow' => true, @@ -59,6 +54,10 @@ class SiteController extends Controller public function actionLogin() { + if (!\Yii::$app->user->isGuest) { + $this->goHome(); + } + $model = new LoginForm(); if ($model->load($_POST) && $model->login()) { return $this->goBack();