diff --git a/controllers/SecurityController.php b/controllers/SecurityController.php index 61028fbb4..a9eff9342 100644 --- a/controllers/SecurityController.php +++ b/controllers/SecurityController.php @@ -143,7 +143,15 @@ public function actions() * @return string|Response */ public function actionLogin() - { + { + //Checking if GET variable *returnUrl* were defined + + $returnUrl=\Yii::$app->request->get('returnUrl',null); + + if (filter_var($returnUrl, FILTER_VALIDATE_URL) === FALSE) { + $returnUrl=null; + } + if (!\Yii::$app->user->isGuest) { $this->goHome(); } @@ -158,7 +166,7 @@ public function actionLogin() if ($model->load(\Yii::$app->getRequest()->post()) && $model->login()) { $this->trigger(self::EVENT_AFTER_LOGIN, $event); - return $this->goBack(); + return $this->goBack($returnUrl); } return $this->render('login', [