Skip to content

Commit

Permalink
Ensuring that 'ext' param added by RequestHandler does not end up as …
Browse files Browse the repository at this point in the history
…a queryString parameter in Auth.redirect.

Adding test case.
Fixes #6211

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8182 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
markstory committed Jun 1, 2009
1 parent 50f4d91 commit 9aa64ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/controller/components/auth.php
Expand Up @@ -339,7 +339,7 @@ function startup(&$controller) {
$this->Session->setFlash($this->authError, 'default', array(), 'auth');
if (!empty($controller->params['url']) && count($controller->params['url']) >= 2) {
$query = $controller->params['url'];
unset($query['url']);
unset($query['url'], $query['ext']);
$url .= Router::queryString($query, array());
}
$this->Session->write('Auth.redirect', $url);
Expand Down
17 changes: 17 additions & 0 deletions cake/tests/cases/libs/controller/components/auth.test.php
Expand Up @@ -728,6 +728,7 @@ function testAllowDenyAll() {
$this->Controller->params['action'] = 'Add';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
}

/**
* testLoginRedirect method
*
Expand Down Expand Up @@ -854,6 +855,22 @@ function testLoginRedirect() {
$this->Controller->Auth->startup($this->Controller);
$expected = Router::normalize('posts/index/29?print=true&refer=menu');
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));

$_GET = array(
'url' => '/posts/index/29',
'print' => 'true',
'refer' => 'menu',
'ext' => 'html'
);
$this->Controller->Session->del('Auth');
$url = '/posts/index/29?print=true&refer=menu';
$this->Controller->params = Dispatcher::parseParams($url);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->startup($this->Controller);
$expected = Router::normalize('posts/index/29?print=true&refer=menu');
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
$_GET = $_back;

//external authed action
Expand Down

0 comments on commit 9aa64ef

Please sign in to comment.