Skip to content
Permalink
Browse files

Allow complex urls for login action.

  • Loading branch information...
dereuromark committed Sep 15, 2016
1 parent 14f960a commit 2a8d9abe20681573fa51f317e931b9011f48ff6b
@@ -406,7 +406,8 @@ protected function _loginActionRedirectUrl()
if (is_array($loginAction)) {
$loginAction['?'][static::QUERY_STRING_REDIRECT] = $currentUrl;
} else {
$loginAction .= '?' . static::QUERY_STRING_REDIRECT . '=' . rawurlencode($currentUrl);
$char = strpos($loginAction, '?') === false ? '?' : '&';
$loginAction .= $char . static::QUERY_STRING_REDIRECT . '=' . urlencode($currentUrl);
}
return $loginAction;
@@ -661,6 +661,30 @@ public function testLoginRedirectQueryString()
$this->assertEquals($expected, $redirectHeader);
}
/**
* @return void
*/
public function testLoginRedirectQueryStringWithComplexLoginActionUrl()
{
$this->Auth->session->delete('Auth');
$url = '/posts/view/29';
$this->Auth->request->addParams(Router::parse($url));
$this->Auth->request->url = $this->Auth->request->here = Router::normalize($url);
$this->Auth->request->query = [
'print' => 'true',
'refer' => 'menu'
];
$this->Auth->session->delete('Auth');
$this->Auth->config('loginAction', '/auth_test/login/passed-param?a=b');
$event = new Event('Controller.startup', $this->Controller);
$response = $this->Auth->startup($event);
$redirectHeader = $response->header()['Location'];
$expected = Router::url(['controller' => 'AuthTest', 'action' => 'login', 'passed-param', '?' => ['a' => 'b', 'redirect' => '/posts/view/29?print=true&refer=menu']], true);
$this->assertEquals($expected, $redirectHeader);
}
/**
* @return void
*/
@@ -1483,7 +1507,7 @@ public function testStatelessAuthNoRedirect()
* @return void
* @triggers Controller.startup $this->Controller
*/
public function testStatelessFollowedByStatefulAuth()
public function testStatelessAuthRedirectToLogin()
{
$this->Auth->response = $this->getMockBuilder('Cake\Network\Response')
->setMethods(['stop', 'statusCode', 'send'])

0 comments on commit 2a8d9ab

Please sign in to comment.
You can’t perform that action at this time.