Skip to content

Commit fe5d3d6

Browse files
committed
Merge #21 Redirect to cloud services landing page after access denied error
2 parents e9b3dd1 + 04dcb99 commit fe5d3d6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/Controller/LoginController.php

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

324324
if ($error !== '') {
325+
if (!$this->isMobileDevice()) {
326+
$cancelRedirectUrl = $this->config->getSystemValue('user_oidc.cancel_redirect_url', 'https://cloud.telekom-dienste.de/');
327+
return new RedirectResponse($cancelRedirectUrl);
328+
}
325329
$this->logger->warning('Code login error', ['error' => $error, 'error_description' => $error_description]);
326330
if ($this->isDebugModeEnabled()) {
327331
return new JSONResponse([
@@ -922,6 +926,22 @@ private function getBackchannelLogoutErrorResponse(
922926
);
923927
}
924928

929+
private function isMobileDevice(): bool {
930+
$mobileKeywords = $this->config->getSystemValue('user_oidc.mobile_keywords', ['Android', 'iPhone', 'iPad', 'iPod', 'Windows Phone', 'Mobile', 'webOS', 'BlackBerry', 'Opera Mini', 'IEMobile']);
931+
932+
if (!isset($_SERVER['HTTP_USER_AGENT'])) {
933+
return false; // if no user-agent is set, assume desktop
934+
}
935+
936+
foreach ($mobileKeywords as $keyword) {
937+
if (stripos($_SERVER['HTTP_USER_AGENT'], $keyword) !== false) {
938+
return true; // device is mobile
939+
}
940+
}
941+
942+
return false; // device is desktop
943+
}
944+
925945
private function toCodeChallenge(string $data): string {
926946
// Basically one big work around for the base64url decode being weird
927947
$h = pack('H*', hash('sha256', $data));

0 commit comments

Comments
 (0)