mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #9840 from chinpei215/2.x-blank-redir
Fix redirectUrl issue when loginRedirect is empty
This commit is contained in:
commit
14192ba1e8
2 changed files with 15 additions and 1 deletions
|
@ -741,7 +741,7 @@ class AuthComponent extends Component {
|
||||||
$this->Session->delete('Auth.redirect');
|
$this->Session->delete('Auth.redirect');
|
||||||
|
|
||||||
if (Router::normalize($redir) === Router::normalize($this->loginAction)) {
|
if (Router::normalize($redir) === Router::normalize($this->loginAction)) {
|
||||||
$redir = $this->loginRedirect;
|
$redir = $this->loginRedirect ?: '/';
|
||||||
}
|
}
|
||||||
} elseif ($this->loginRedirect) {
|
} elseif ($this->loginRedirect) {
|
||||||
$redir = $this->loginRedirect;
|
$redir = $this->loginRedirect;
|
||||||
|
|
|
@ -1652,6 +1652,20 @@ class AuthComponentTest extends CakeTestCase {
|
||||||
Router::reload();
|
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
|
* test password hashing
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue