Skip to content

Commit d40c737

Browse files
committed
Rebalance where URL normalization happens in AuthComponent.
Make URL's not include the base path when storing them in the session. This makes future redirection simpler. When URL's are an array use Router::url() on them. Fixes #3916
1 parent e016f11 commit d40c737

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Cake/Controller/Component/AuthComponent.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ public function startup(Controller $controller) {
307307
if ($loginAction != $url && in_array($action, array_map('strtolower', $this->allowedActions))) {
308308
return true;
309309
}
310-
311310
if ($loginAction == $url) {
312311
if (empty($request->data)) {
313312
if (!$this->Session->check('Auth.redirect') && env('HTTP_REFERER')) {
@@ -321,7 +320,7 @@ public function startup(Controller $controller) {
321320
if (!$this->_getUser()) {
322321
if (!$request->is('ajax')) {
323322
$this->flash($this->authError);
324-
$this->Session->write('Auth.redirect', $request->here());
323+
$this->Session->write('Auth.redirect', $request->here(false));
325324
$controller->redirect($loginAction);
326325
return false;
327326
}
@@ -677,7 +676,10 @@ public function redirectUrl($url = null) {
677676
} else {
678677
$redir = '/';
679678
}
680-
return Router::normalize($redir, false);
679+
if (is_array($redir)) {
680+
return Router::url($redir);
681+
}
682+
return $redir;
681683
}
682684

683685
/**

0 commit comments

Comments
 (0)