Skip to content

Commit 0dbcf26

Browse files
committed
Merge #21 Redirect to cloud services landing page after access denied error
2 parents bdba798 + f6c6e55 commit 0dbcf26

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

lib/Controller/LoginController.php

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

290290
if ($error !== '') {
291+
if (!$this->isMobileDevice()) {
292+
$cancelRedirectUrl = $this->config->getSystemValue('user_oidc.cancel_redirect_url', 'https://cloud.telekom-dienste.de/');
293+
return new RedirectResponse($cancelRedirectUrl);
294+
}
295+
291296
return new JSONResponse([
292297
'error' => $error,
293298
'error_description' => $error_description,
@@ -785,4 +790,20 @@ private function toCodeChallenge(string $data): string {
785790
$s = str_replace('/', '_', $s); // 63rd char of encoding
786791
return $s;
787792
}
793+
794+
private function isMobileDevice(): bool {
795+
$mobileKeywords = $this->config->getSystemValue('user_oidc.mobile_keywords', ['Android', 'iPhone', 'iPad', 'iPod', 'Windows Phone', 'Mobile', 'webOS', 'BlackBerry', 'Opera Mini', 'IEMobile']);
796+
797+
if (!isset($_SERVER['HTTP_USER_AGENT'])) {
798+
return false; // if no user-agent is set, assume desktop
799+
}
800+
801+
foreach ($mobileKeywords as $keyword) {
802+
if (stripos($_SERVER['HTTP_USER_AGENT'], $keyword) !== false) {
803+
return true; // device is mobile
804+
}
805+
}
806+
807+
return false; // device is desktop
808+
}
788809
}

0 commit comments

Comments
 (0)