Skip to content
Snippets Groups Projects
Commit d4261d9a authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fix personal redirect, fixes #5030

Closes #5030

Merge request studip/studip!3769
parent bf3b25b5
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,9 @@ final class AuthenticationMiddleware implements MiddlewareInterface
if ($this->auth_manager->start()) {
return $handler->handle($request);
} else {
$_SESSION['redirect_after_login'] = \Request::url();
if (!match_route('dispatch.php/start')) {
$_SESSION['redirect_after_login'] = \Request::url();
}
$response = $this->response_factory->createResponse(302);
return $response->withHeader('Location', \URLHelper::getURL('dispatch.php/login'));
}
......
......@@ -61,6 +61,7 @@ final class SeminarOpenMiddleware implements MiddlewareInterface
$jump_page = 'dispatch.php/contents/overview';
break;
}
$response = $this->response_factory->createResponse(302);
return $response->withHeader('Location', \URLHelper::getURL($jump_page));
}
......@@ -97,10 +98,7 @@ final class SeminarOpenMiddleware implements MiddlewareInterface
// user init starts here
if (is_object($user) && $user->id != "nobody") {
if ($_SESSION['SessionStart'] > \UserConfig::get(
$user->id
)->CURRENT_LOGIN_TIMESTAMP
) { // just logged in
if ($_SESSION['SessionStart'] > \UserConfig::get($user->id)->CURRENT_LOGIN_TIMESTAMP) { // just logged in
// store old CURRENT_LOGIN in LAST_LOGIN and set CURRENT_LOGIN to start of session
\UserConfig::get($user->id)->store(
'LAST_LOGIN_TIMESTAMP', \UserConfig::get($user->id)->CURRENT_LOGIN_TIMESTAMP
......@@ -110,10 +108,10 @@ final class SeminarOpenMiddleware implements MiddlewareInterface
$current_sem = \Semester::findDefault();
$_SESSION['_default_sem'] = $current_sem->semester_id ?? null;
//redirect user to another page if he want to, redirect is deferred to allow plugins to catch the UserDidLogin notification
if (\UserConfig::get($user->id)->PERSONAL_STARTPAGE > 0 && !isset($_SESSION['redirect_after_login'])
&& !$perm->have_perm(
"root"
)
if (
\UserConfig::get($user->id)->PERSONAL_STARTPAGE > 0
&& !isset($_SESSION['redirect_after_login'])
&& !$perm->have_perm('root')
) {
$seminar_open_redirected = true;
}
......@@ -247,11 +245,12 @@ final class SeminarOpenMiddleware implements MiddlewareInterface
}
if ($seminar_open_redirected) {
$this->startpageRedirect(\UserConfig::get($user->id)->PERSONAL_STARTPAGE);
return $this->startpageRedirect(\UserConfig::get($user->id)->PERSONAL_STARTPAGE);
}
// Show terms on first login
if (is_object($GLOBALS['user'])
if (
is_object($GLOBALS['user'])
&& $GLOBALS['user']->needsToAcceptTerms()
&& !match_route('dispatch.php/terms')
&& !match_route('dispatch.php/siteinfo/*')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment