Skip to content

Commit 33b36ec

Browse files
committed
Merge #21 Redirect to cloud services landing page after access denied error
2 parents d46bbb1 + 4ee1543 commit 33b36ec

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

304304
if ($error !== '') {
305+
if (!$this->isMobileDevice()) {
306+
$cancelRedirectUrl = $this->config->getSystemValue('user_oidc.cancel_redirect_url', 'https://cloud.telekom-dienste.de/');
307+
return new RedirectResponse($cancelRedirectUrl);
308+
}
309+
305310
return new JSONResponse([
306311
'error' => $error,
307312
'error_description' => $error_description,
@@ -802,6 +807,22 @@ private function getBackchannelLogoutErrorResponse(
802807
);
803808
}
804809

810+
private function isMobileDevice(): bool {
811+
$mobileKeywords = $this->config->getSystemValue('user_oidc.mobile_keywords', ['Android', 'iPhone', 'iPad', 'iPod', 'Windows Phone', 'Mobile', 'webOS', 'BlackBerry', 'Opera Mini', 'IEMobile']);
812+
813+
if (!isset($_SERVER['HTTP_USER_AGENT'])) {
814+
return false; // if no user-agent is set, assume desktop
815+
}
816+
817+
foreach ($mobileKeywords as $keyword) {
818+
if (stripos($_SERVER['HTTP_USER_AGENT'], $keyword) !== false) {
819+
return true; // device is mobile
820+
}
821+
}
822+
823+
return false; // device is desktop
824+
}
825+
805826
private function toCodeChallenge(string $data): string {
806827
// Basically one big work around for the base64url decode being weird
807828
$h = pack('H*', hash('sha256', $data));

0 commit comments

Comments
 (0)