Procházet zdrojové kódy

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

Alexander Makarov před 12 roky
rodič
revize
4df6370173
1 změnil soubory, kde provedl 5 přidání a 6 odebrání
  1. 5 6
      controllers/SiteController.php

+ 5 - 6
controllers/SiteController.php

@@ -16,14 +16,9 @@ class SiteController extends Controller
 		return [
 		return [
 			'access' => [
 			'access' => [
 				'class' => AccessControl::className(),
 				'class' => AccessControl::className(),
-				'only' => ['login', 'logout'],
+				'only' => ['logout'],
 				'rules' => [
 				'rules' => [
 					[
 					[
-						'actions' => ['login'],
-						'allow' => true,
-						'roles' => ['?'],
-					],
-					[
 						'actions' => ['logout'],
 						'actions' => ['logout'],
 						'allow' => true,
 						'allow' => true,
 						'roles' => ['@'],
 						'roles' => ['@'],
@@ -59,6 +54,10 @@ class SiteController extends Controller
 
 
 	public function actionLogin()
 	public function actionLogin()
 	{
 	{
+		if (!\Yii::$app->user->isGuest) {
+			$this->goHome();
+		}
+
 		$model = new LoginForm();
 		$model = new LoginForm();
 		if ($model->load($_POST) && $model->login()) {
 		if ($model->load($_POST) && $model->login()) {
 			return $this->goBack();
 			return $this->goBack();