فهرست منبع

Modified application templates so when trying to log in when already logged in it just redirects to homepage instead of throwing exceptions

Alexander Makarov 12 سال پیش
والد
کامیت
4df6370173
1فایلهای تغییر یافته به همراه5 افزوده شده و 6 حذف شده
  1. 5 6
      controllers/SiteController.php

+ 5 - 6
controllers/SiteController.php

@@ -16,14 +16,9 @@ class SiteController extends Controller
 		return [
 			'access' => [
 				'class' => AccessControl::className(),
-				'only' => ['login', 'logout'],
+				'only' => ['logout'],
 				'rules' => [
 					[
-						'actions' => ['login'],
-						'allow' => true,
-						'roles' => ['?'],
-					],
-					[
 						'actions' => ['logout'],
 						'allow' => true,
 						'roles' => ['@'],
@@ -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();