diff --git a/userdemo/module/User/src/Controller/AuthController.php b/userdemo/module/User/src/Controller/AuthController.php index 76ab1ec..1347f6e 100644 --- a/userdemo/module/User/src/Controller/AuthController.php +++ b/userdemo/module/User/src/Controller/AuthController.php @@ -88,21 +88,19 @@ public function loginAction() // Get redirect URL. $redirectUrl = $this->params()->fromPost('redirect_url', ''); - + + // If redirect URL is provided, redirect the user to that URL; + // otherwise redirect to Home page. if (!empty($redirectUrl)) { // The below check is to prevent possible redirect attack // (if someone tries to redirect user to another domain). $uri = new Uri($redirectUrl); - if (!$uri->isValid() || $uri->getHost()!=null) + if (!$uri->isValid() || $uri->getHost()!=null) { throw new \Exception('Incorrect redirect URL: ' . $redirectUrl); - } - - // If redirect URL is provided, redirect the user to that URL; - // otherwise redirect to Home page. - if(empty($redirectUrl)) { - return $this->redirect()->toRoute('home'); - } else { + } $this->redirect()->toUrl($redirectUrl); + } else { + return $this->redirect()->toRoute('home'); } } else { $isLoginError = true;