Skip to content

Commit 47714ec

Browse files
committed
Merge #21 Redirect to cloud services landing page after access denied error
2 parents c7e9744 + 4ee1543 commit 47714ec

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
@@ -303,6 +303,11 @@ public function code(string $state = '', string $code = '', string $scope = '',
303303
$this->logger->debug('Code login with core: ' . $code . ' and state: ' . $state);
304304

305305
if ($error !== '') {
306+
if (!$this->isMobileDevice()) {
307+
$cancelRedirectUrl = $this->config->getSystemValue('user_oidc.cancel_redirect_url', 'https://cloud.telekom-dienste.de/');
308+
return new RedirectResponse($cancelRedirectUrl);
309+
}
310+
306311
return new JSONResponse([
307312
'error' => $error,
308313
'error_description' => $error_description,
@@ -836,6 +841,22 @@ private function getBackchannelLogoutErrorResponse(
836841
);
837842
}
838843

844+
private function isMobileDevice(): bool {
845+
$mobileKeywords = $this->config->getSystemValue('user_oidc.mobile_keywords', ['Android', 'iPhone', 'iPad', 'iPod', 'Windows Phone', 'Mobile', 'webOS', 'BlackBerry', 'Opera Mini', 'IEMobile']);
846+
847+
if (!isset($_SERVER['HTTP_USER_AGENT'])) {
848+
return false; // if no user-agent is set, assume desktop
849+
}
850+
851+
foreach ($mobileKeywords as $keyword) {
852+
if (stripos($_SERVER['HTTP_USER_AGENT'], $keyword) !== false) {
853+
return true; // device is mobile
854+
}
855+
}
856+
857+
return false; // device is desktop
858+
}
859+
839860
private function toCodeChallenge(string $data): string {
840861
// Basically one big work around for the base64url decode being weird
841862
$h = pack('H*', hash('sha256', $data));

0 commit comments

Comments
 (0)