Files
desktop/public/index.php
Lars Gebhardt-Kusche 2c3c84e66f
All checks were successful
Deploy / deploy-staging (push) Successful in 24s
Deploy / deploy-production (push) Has been skipped
adasdas
2026-06-15 23:19:24 +02:00

49 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
require_once dirname(__DIR__) . '/src/App/bootstrap.php';
use App\App;
use App\AccountGate;
use App\ConfigLoader;
use App\KeycloakAuth;
session_start();
$projectRoot = dirname(__DIR__);
$keycloakConfig = ConfigLoader::load($projectRoot, 'keycloak');
$registrationConfig = ConfigLoader::load($projectRoot, 'registration');
$auth = new KeycloakAuth($keycloakConfig);
$accountGate = new AccountGate($registrationConfig);
if ($auth->isAuthenticated()) {
$currentUser = is_array($_SESSION['desktop_auth']['user'] ?? null) ? $_SESSION['desktop_auth']['user'] : [];
$accountCheck = $accountGate->checkUsername((string) ($currentUser['username'] ?? ''));
if (!($accountCheck['allowed'] ?? false)) {
$auth->logout();
$target = (string) ($accountCheck['state'] ?? '') === 'pending'
? '/auth/pending/?username=' . urlencode((string) ($currentUser['username'] ?? ''))
: '/auth/inactive/?message=' . urlencode((string) ($accountCheck['message'] ?? 'Dieses Konto ist noch nicht freigeschaltet.'));
header('Location: ' . $target, true, 302);
exit;
}
}
if (!$auth->shouldShowDesktop()) {
if ($auth->isConfigured()) {
header('Location: /auth/keycloak', true, 302);
exit;
}
http_response_code(503);
echo 'Keycloak ist nicht konfiguriert.';
exit;
}
$app = new App($projectRoot);
$desktopPayload = $app->desktopPayload();
require $projectRoot . '/partials/desktop/shell.php';