diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index fd9b2dd1..de5639fe 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -97,6 +97,12 @@ private function registerRedirect(IRequest $request, IURLGenerator $urlGenerator // in case any errors happen when checking for the path do not apply redirect logic as it is only needed for the login } if ($isDefaultLogin && !$settings->getAllowMultipleUserBackEnds() && count($providers) === 1) { + // To avoid login/logout loop if the IdP session is still alive: + // if the login page's redirect_url GET param is the logout page, just use the base URL instead + $logoutUrl = $urlGenerator->linkToRoute('core.login.logout'); + if (strpos($redirectUrl, $logoutUrl) !== false) { + $redirectUrl = $urlGenerator->getBaseUrl(); + } $targetUrl = $urlGenerator->linkToRoute(self::APP_ID . '.login.login', [ 'providerId' => $providers[0]->getId(), 'redirectUrl' => $redirectUrl