Merge pull request #9840 from chinpei215/2.x-blank-redir

Fix redirectUrl issue when loginRedirect is empty
This commit is contained in:
Mark Story 2016-12-04 09:26:19 -05:00 committed by GitHub
commit 14192ba1e8
2 changed files with 15 additions and 1 deletions

View file

@ -741,7 +741,7 @@ class AuthComponent extends Component {
$this->Session->delete('Auth.redirect');
if (Router::normalize($redir) === Router::normalize($this->loginAction)) {
$redir = $this->loginRedirect;
$redir = $this->loginRedirect ?: '/';
}
} elseif ($this->loginRedirect) {
$redir = $this->loginRedirect;

View file

@ -1652,6 +1652,20 @@ class AuthComponentTest extends CakeTestCase {
Router::reload();
}
/**
* Test that redirectUrl() returns '/' if loginRedirect is empty
* and Auth.redirect is the login page.
*
* @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();
$this->assertEquals('/', $result);
}
/**
* test password hashing
*