Skip to content

Commit 1ed8442

Browse files
committed
Merge #27 [V33] Redirect after access denied error
2 parents 66b80f8 + 8c19fdc commit 1ed8442

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/Controller/LoginController.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ public function code(string $state = '', string $code = '', string $scope = '',
321321
$this->logger->debug('Code login with core: ' . $code . ' and state: ' . $state);
322322

323323
if ($error !== '') {
324+
if (!$this->isMobileDevice()) {
325+
$cancelRedirectUrl = $this->config->getSystemValue('user_oidc.cancel_redirect_url', 'https://cloud.telekom-dienste.de/');
326+
return new RedirectResponse($cancelRedirectUrl);
327+
}
328+
324329
$this->logger->warning('Code login error', ['error' => $error, 'error_description' => $error_description]);
325330
if ($this->isDebugModeEnabled()) {
326331
return new JSONResponse([
@@ -910,4 +915,20 @@ private function toCodeChallenge(string $data): string {
910915
$s = str_replace('/', '_', $s); // 63rd char of encoding
911916
return $s;
912917
}
918+
919+
private function isMobileDevice(): bool {
920+
$mobileKeywords = $this->config->getSystemValue('user_oidc.mobile_keywords', ['Android', 'iPhone', 'iPad', 'iPod', 'Windows Phone', 'Mobile', 'webOS', 'BlackBerry', 'Opera Mini', 'IEMobile']);
921+
922+
if (!isset($_SERVER['HTTP_USER_AGENT'])) {
923+
return false; // if no user-agent is set, assume desktop
924+
}
925+
926+
foreach ($mobileKeywords as $keyword) {
927+
if (stripos($_SERVER['HTTP_USER_AGENT'], $keyword) !== false) {
928+
return true; // device is mobile
929+
}
930+
}
931+
932+
return false; // device is desktop
933+
}
913934
}

0 commit comments

Comments
 (0)