diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 29a0e49b3..54e7034ab 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -741,10 +741,7 @@ class AuthComponent extends Component { $this->Session->delete('Auth.redirect'); if (Router::normalize($redir) === Router::normalize($this->loginAction)) { - $redir = $this->loginRedirect; - if (!$redir) { - $redir = '/'; - } + $redir = $this->loginRedirect ?: '/'; } } elseif ($this->loginRedirect) { $redir = $this->loginRedirect; diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index e8f674e77..5da15d1e9 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -1659,6 +1659,7 @@ class AuthComponentTest extends CakeTestCase { * @return void */ public function testRedirectUrlWithoutLoginRedirect() { + $this->Auth->loginRedirect = null; $this->Auth->Session->write('Auth.redirect', '/users/login'); $this->Auth->request->addParams(Router::parse('/users/login')); $result = $this->Auth->redirectUrl();