Skip to content

Commit

Permalink
Adding omitted return that would prevent users from reaching the logi…
Browse files Browse the repository at this point in the history
…n page after being redirected to it. Tests added. Fixes #1542
  • Loading branch information
markstory committed Feb 17, 2011
1 parent c638443 commit 5c4854b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/controller/components/auth.php
Expand Up @@ -311,6 +311,7 @@ public function startup($controller) {
$this->Session->write('Auth.redirect', $controller->referer(null, true));
}
}
return true;
} else {
if (!$this->_getUser()) {
if (!$request->is('ajax')) {
Expand All @@ -328,7 +329,6 @@ public function startup($controller) {
}
}
}

if (empty($this->authorize) || $this->isAuthorized()) {
return true;
}
Expand Down
21 changes: 21 additions & 0 deletions cake/tests/cases/libs/controller/components/auth.test.php
Expand Up @@ -866,6 +866,27 @@ function testLoginRedirect() {
$this->Auth->Session->delete('Auth');
}

/**
* test that no redirects or authoization tests occur on the loginAction
*
* @return void
*/
function testNoRedirectOnLoginAction() {
$controller = $this->getMock('Controller');
$controller->methods = array('login');

$url = '/AuthTest/login';
$this->Auth->request = $controller->request = new CakeRequest($url);
$this->Auth->request->addParams(Router::parse($url));
$this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Auth->authorize = array('Controller');

$controller->expects($this->never())
->method('redirect');

$this->Auth->startup($controller);
}

/**
* Ensure that no redirect is performed when a 404 is reached
* And the user doesn't have a session.
Expand Down

0 comments on commit 5c4854b

Please sign in to comment.