Use ternary operator

This commit is contained in:
chinpei215 2016-12-04 21:55:29 +09:00
parent b7481096c8
commit 26731b93bf
2 changed files with 2 additions and 4 deletions

View file

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

View file

@ -1659,6 +1659,7 @@ class AuthComponentTest extends CakeTestCase {
* @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();