fix: [redirect] Correctly redirect to the requested URL after a login, fixes #4005, fixes #1301

pull/4075/head
iglocska 2019-01-28 17:02:04 +01:00
parent 3676000075
commit 9afd0d8600
2 changed files with 6 additions and 1 deletions

View File

@ -333,6 +333,7 @@ class AppController extends Controller
}
} else {
if (!($this->params['controller'] === 'users' && $this->params['action'] === 'login')) {
$this->Session->write('pre_login_requested_url', $this->here);
$this->redirect(array('controller' => 'users', 'action' => 'login', 'admin' => false));
}
}

View File

@ -1065,7 +1065,11 @@ class UsersController extends AppController
public function routeafterlogin()
{
// Events list
$this->redirect(array('controller' => 'events', 'action' => 'index'));
$url = $this->Session->consume('pre_login_requested_url');
if (empty($url)) {
$url = array('controller' => 'events', 'action' => 'index');
}
$this->redirect($url);
}
public function logout()