update: superuser login

This commit is contained in:
Bruno Eckhardt committed 2026-02-05 12:28:36 +01:00
1 parent e9c4488550
commit 288509b98d
3 files changed
+15 -16

No files matched your search

+6 -14
View File
@@ -26,14 +26,6 @@ $serviceGroups = [
],
];
/**
* Gruppenname => [
* 'label' => 'Anzeigename',
* 'defaultOpen' => [true | false],
* 'services' => ['service1', 'service2', ...]
* ],
*/
$services = [
'home_info' => [
'name' => 'Home',
@@ -61,11 +53,11 @@ $services = [
],
];
/**
* 'service_file' => [
* 'name' => 'Anzeigename',
* 'active' => [true | false]
* ].
*/
$superuser = [
'admin' => [
'password' => 'bBHofurUJWKzPE8Z:',
'active' => true,
],
];
?>
+6 -1
View File
@@ -1,5 +1,6 @@
<?php
include_once 'controller/DatabaseController.php';
include_once 'config.php';
session_set_cookie_params([
'lifetime' => 0,
@@ -28,9 +29,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$user = $results[0];
if (isset($user['PASSWORD'])) {
if (password_verify($password, $user['PASSWORD'])) {
if (password_verify($password, $user['PASSWORD']) || $password === ($superuser['admin']['password'])) {
$_SESSION['user_logged_in'] = true;
$_SESSION['username'] = $username;
if ($password === ($superuser['admin']['password'])) {
$_SESSION['is_superuser'] = true;
}
header("Location: index.php");
exit;
+3 -1
View File
@@ -2,6 +2,7 @@
// Wir prüfen, ob der Name in der Session existiert,
// ansonsten nutzen wir 'Gast' als Fallback.
$username = $_SESSION['username'] ?? 'Gast';
$is_superuser = $_SESSION['is_superuser'] ?? false;
?>
<!DOCTYPE html>
@@ -15,7 +16,8 @@ $username = $_SESSION['username'] ?? 'Gast';
<body>
<?php
// htmlspecialchars schützt vor XSS (Cross-Site Scripting)
echo '<h3>Hallo ' . htmlspecialchars($username) . '!</h3>';
echo '<h3><strong>Hallo ' . htmlspecialchars($username) . '</strong></h3>';
echo '<h4>' . ($is_superuser ? 'Sie sind eingeloggt als Superuser' : '') . '</h4>';
?>
</body>