Files
desktop/public/index.php
Lars Gebhardt-Kusche 033fdfd598
All checks were successful
Deploy / deploy-staging (push) Successful in 24s
Deploy / deploy-production (push) Has been skipped
dadasd
2026-06-15 22:15:01 +02:00

46 lines
1.3 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();
header('Location: /auth/inactive/?message=' . urlencode((string) ($accountCheck['message'] ?? 'Dieses Konto ist noch nicht freigeschaltet.')), 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';