Skip to content

Commit

Permalink
Merge #21 Redirect to cloud services landing page after access denied…
Browse files Browse the repository at this point in the history
… error
  • Loading branch information
memurats committed Feb 4, 2025
2 parents bdba798 + f6c6e55 commit 0dbcf26
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ public function code(string $state = '', string $code = '', string $scope = '',
$this->logger->debug('Code login with core: ' . $code . ' and state: ' . $state);

if ($error !== '') {
if (!$this->isMobileDevice()) {
$cancelRedirectUrl = $this->config->getSystemValue('user_oidc.cancel_redirect_url', 'https://cloud.telekom-dienste.de/');
return new RedirectResponse($cancelRedirectUrl);
}

return new JSONResponse([
'error' => $error,
'error_description' => $error_description,
Expand Down Expand Up @@ -785,4 +790,20 @@ private function toCodeChallenge(string $data): string {
$s = str_replace('/', '_', $s); // 63rd char of encoding
return $s;
}

private function isMobileDevice(): bool {
$mobileKeywords = $this->config->getSystemValue('user_oidc.mobile_keywords', ['Android', 'iPhone', 'iPad', 'iPod', 'Windows Phone', 'Mobile', 'webOS', 'BlackBerry', 'Opera Mini', 'IEMobile']);

if (!isset($_SERVER['HTTP_USER_AGENT'])) {
return false; // if no user-agent is set, assume desktop
}

foreach ($mobileKeywords as $keyword) {
if (stripos($_SERVER['HTTP_USER_AGENT'], $keyword) !== false) {
return true; // device is mobile
}
}

return false; // device is desktop
}
}

0 comments on commit 0dbcf26

Please sign in to comment.