28 lines
1.1 KiB
PHP
28 lines
1.1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/includes/users.php';
|
|
if (!bg_config_exists()) {
|
|
header('Location: setup.php');
|
|
exit;
|
|
}
|
|
if (!bg_validate_user_session()) {
|
|
// Legacy sessions are deliberately invalidated after this security update.
|
|
$_SESSION = [];
|
|
session_regenerate_id(true);
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
// Initial BastionGuard application wizard gate: after WebPanel setup/login,
|
|
// administrators are sent to the BastionGuard wizard until ~/.config/BastionGuard/config.json
|
|
// exists, is valid and has wizard_completed=true with the service map.
|
|
$__bg_script = basename((string)($_SERVER['SCRIPT_NAME'] ?? ''));
|
|
if (!in_array($__bg_script, ['wizard.php', 'health.php'], true) && function_exists('bg_current_user_is_admin') && bg_current_user_is_admin()) {
|
|
require_once __DIR__ . '/includes/config_manager.php';
|
|
$opts = bg_web_options();
|
|
$target = trim((string)($opts['desktop_user'] ?? bg_detect_desktop_user()));
|
|
$st = bg_wizard_config_status($target ?: null);
|
|
if (empty($st['completed']) || empty($st['services_ok'])) {
|
|
header('Location: wizard.php?first=1');
|
|
exit;
|
|
}
|
|
}
|
|
?>
|