Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strips the base off the generated URL from the AuthComponent. #1451

Merged
merged 1 commit into from Jul 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/AuthComponent.php
Expand Up @@ -677,7 +677,7 @@ public function redirectUrl($url = null) {
$redir = '/';
}
if (is_array($redir)) {
return Router::url($redir);
return Router::url($redir + array('base' => false));
}
return $redir;
}
Expand Down
35 changes: 35 additions & 0 deletions lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php
Expand Up @@ -1268,6 +1268,41 @@ public function testRedirectSessionReadEqualToLoginAction() {
$this->assertFalse($this->Auth->Session->check('Auth.redirect'));
}

/**
* test that the returned URL doesn't contain the base URL.
*
* @see https://cakephp.lighthouseapp.com/projects/42648/tickets/3922-authcomponentredirecturl-prepends-appbaseurl
*
* @return void This test method doesn't return anything.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bigsmile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I aim to please.

*/
public function testRedirectUrlWithBaseSet() {
$App = Configure::read('App');

Configure::write('App', array(
'dir' => APP_DIR,
'webroot' => WEBROOT_DIR,
'base' => false,
'baseUrl' => '/cake/index.php'
));

$url = '/users/login';
$this->Auth->request = $this->Controller->request = new CakeRequest($url);
$this->Auth->request->addParams(Router::parse($url));
$this->Auth->request->url = Router::normalize($url);

Router::setRequestInfo($this->Auth->request);

$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'home');

$result = $this->Auth->redirectUrl();
$this->assertEquals('/users/home', $result);
$this->assertFalse($this->Auth->Session->check('Auth.redirect'));

Configure::write('App', $App);
Router::reload();
}

/**
* test password hashing
*
Expand Down