web - refactor core modules, harden authorization, simplify endpoints

This commit is contained in:
2026-08-29 11:15:54 +02:00
parent e1109a07ef
commit 79d857d686
71 changed files with 8269 additions and 9119 deletions
@@ -1,111 +1,136 @@
<?php /* Name: signup.php
Beschreibung: Registrierungsformular (vereint)
- Wenn Nutzer vorregistriert: direkte Registrierung
- Wenn nicht: Antrag wird automatisch gestellt
- Verwendet signup-process.php */
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/intranet_repo/general_files/ini/parameters.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/intranet_repo/general_files/ini/functions.php';
require_once __DIR__ . '/util/authorization_helpers.php';
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/general_files/ini/parameters.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/general_files/ini/functions.php';
authorization_start_session();
authorization_send_security_headers();
if (isset($_SESSION['user_id'])) {
authorization_redirect($g_httpHomePath, 302);
}
$form = authorization_registration_input([]);
$error = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$form = authorization_registration_input($_POST);
if (!authorization_csrf_is_valid($_POST['csrf_token'] ?? null)) {
$error = 'Die Anfrage konnte nicht bestätigt werden. Bitte laden Sie die Seite neu und versuchen Sie es erneut.';
} else {
$error = authorization_registration_error($form);
}
if ($error === null) {
try {
$pdo = require $_SERVER['DOCUMENT_ROOT'] . '/intranet_repo/general_files/ini/database.php';
$result = authorization_register($pdo, $form);
if ($result['status'] === 'pending') {
try {
require_once $_SERVER['DOCUMENT_ROOT'] . '/intranet_repo/general_files/ini/send_mail.php';
$mailSubject = "Neue Registrierungsanfrage von {$form['first_name']} {$form['last_name']}";
$mailMessage = "Es liegt eine neue Registrierungsanfrage vor:\n\n"
. "Name: {$form['first_name']} {$form['last_name']}\n"
. "E-Mail: {$form['email']}\n"
. "Telefon: {$form['phone']}\n\n"
. 'Bitte melden Sie sich im Adminpanel an, um die Anfrage zu bearbeiten.';
send_admin_team_mail(
$pdo,
$mailSubject,
$mailMessage,
'Im Adminpanel bearbeiten',
authorization_public_url('/intranet_repo/projects/adminpanel/admin_inbox.php')
);
} catch (Throwable $e) {
// Die Anfrage ist bereits atomar gespeichert; Mailfehler dürfen keine Doppelregistrierung provozieren.
error_log('authorization signup notification failed: ' . $e->getMessage());
}
}
authorization_redirect('signup.php?success=1');
} catch (Throwable $e) {
error_log('authorization signup failed: ' . $e->getMessage());
$error = 'Die Registrierung konnte nicht verarbeitet werden. Bitte versuchen Sie es erneut.';
}
}
}
$csrfToken = authorization_csrf_token();
?>
<!DOCTYPE html>
<html lang="de" dir="ltr">
<head>
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/projects/_central/php/html_head.php'; ?>
<!-- Quelle für just-validate.js: https://unpkg.com/just-validate@latest/dist/just-validate.production.min.js -->
<script src="just-validate.js" defer></script>
<script src="validation.js" defer></script>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/intranet_repo/projects/_central/php/html_head.php'; ?>
<link rel="stylesheet" href="/intranet_repo/projects/_central/layouts/authorization.css">
<script src="just-validate.js" defer></script>
<script src="/intranet_repo/projects/_central/scripts/authorization.js" defer></script>
</head>
<body>
<div class="login_panel">
<div class="login_panel">
<?php if ($error !== null): ?>
<div class="nak-toast nak-toast--error nak-toast--inline" data-auth-toast>
<div class="nak-toast__icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg></div>
<span class="nak-toast__text"><?= authorization_html($error) ?></span>
</div>
<?php endif; ?>
<?php if (isset($_GET["error"])): ?>
<?php if ($_GET["error"] == 1): ?>
<div class="nak-toast nak-toast--error nak-toast--inline" id="nakToastErr">
<div class="nak-toast__icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg></div>
<span class="nak-toast__text">Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.</span>
</div>
<script>requestAnimationFrame(function(){document.getElementById('nakToastErr').classList.add('nak-toast--visible');});</script>
<?php elseif ($_GET["error"] == 2): ?>
<div class="nak-toast nak-toast--error nak-toast--inline" id="nakToastErr">
<div class="nak-toast__icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg></div>
<span class="nak-toast__text">Diese E-Mailadresse ist bereits registriert oder es liegt bereits eine Anfrage vor.</span>
</div>
<script>requestAnimationFrame(function(){document.getElementById('nakToastErr').classList.add('nak-toast--visible');});</script>
<?php endif; ?>
<?php endif; ?>
<?php if (($_GET['success'] ?? '') === '1'): ?>
<div class="nak-toast nak-toast--success nak-toast--inline" data-auth-toast>
<div class="nak-toast__icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="square" stroke-linejoin="miter"><path d="M20 6L9 17l-5-5"/></svg></div>
<span class="nak-toast__text">Ihre Angaben wurden verarbeitet. Falls Ihr Konto direkt aktiviert werden konnte, können Sie sich anmelden. Andernfalls erhalten Sie nach der Prüfung eine Benachrichtigung.</span>
</div>
<?php endif; ?>
<?php if (isset($_GET["success"]) && $_GET["success"] == 1): ?>
<div class="nak-toast nak-toast--success nak-toast--inline" id="nakToastOk">
<div class="nak-toast__icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="square" stroke-linejoin="miter"><path d="M20 6L9 17l-5-5"/></svg></div>
<span class="nak-toast__text">Ihre Registrierung wurde beantragt. Sie erhalten eine Benachrichtigung, sobald Ihr Konto freigeschaltet wurde.</span>
</div>
<script>requestAnimationFrame(function(){document.getElementById('nakToastOk').classList.add('nak-toast--visible');});</script>
<?php endif; ?>
<div class="login_content">
<div class="nak-logo-link auth-logo">
<img class="auth-logo__icon" src="/intranet_repo/projects/_central/img/nak-logo.svg" alt="NAK Logo">
<div class="auth-logo__text">
<div class="auth-logo__name">Neuapostolische Kirche</div>
<div class="auth-logo__gemeinde">Berlin-Reinickendorf</div>
</div>
</div>
<h2>Registrieren</h2>
<p style="text-align:center;color:var(--gray-600);font-size:var(--font-size-sm);margin-bottom:var(--space-sm);">Erstellen Sie Ihren persönlichen Zugang zum Intranet.</p>
<div class="login_content">
<div class="nak-logo-link auth-logo">
<img class="auth-logo__icon" src="/intranet_repo/projects/_central/img/nak-logo.svg" alt="NAK Logo">
<div class="auth-logo__text">
<div class="auth-logo__name">Neuapostolische Kirche</div>
<div class="auth-logo__gemeinde">Berlin-Reinickendorf</div>
</div>
</div>
<h2>Registrieren</h2>
<p style="text-align:center;color:var(--gray-600);font-size:var(--font-size-sm);margin-bottom:var(--space-sm);">Erstellen Sie Ihren persönlichen Zugang zum Intranet.</p>
<form action="signup-process.php" method="post" id="signup" novalidate>
<label for="first_name">Vorname</label>
<div class="item">
<input class="login_field" type="text" id="first_name" name="first_name">
</div>
<label for="last_name">Nachname</label>
<div class="item">
<input class="login_field" type="text" id="last_name" name="last_name">
</div>
<label for="email">E-Mailadresse</label>
<div class="item">
<input class="login_field" type="email" id="email" name="email">
</div>
<form method="post" id="signup" novalidate autocomplete="on">
<input type="hidden" name="csrf_token" value="<?= authorization_html($csrfToken) ?>">
<label for="phone">Telefonnummer</label>
<div class="item">
<div style="display:flex;align-items:stretch;width:100%;max-width:100%;margin-bottom:10px;box-sizing:border-box;">
<div class="input-prefix" style="border-radius:0;border:1px solid var(--gray-300);border-right:none;margin:0;padding:14px 12px;font-weight:500;box-shadow:none;width:auto;background:var(--gray-200);color:var(--gray-700);display:flex;align-items:center;flex-shrink:0;">+49</div>
<input class="login_field" type="tel" id="phone" name="phone" style="border-radius:0;border-left:0;margin:0;flex:1;width:auto;min-width:0;">
</div>
</div>
<label for="password">Passwort</label>
<div class="item">
<input class="login_field" type="password" id="password" name="password">
</div>
<label for="password_confirmation">Passwort wiederholen</label>
<div class="item">
<input class="login_field" type="password" id="password_confirmation" name="password_confirmation">
</div>
<input class="login_button" type="submit" value="Registrieren">
</form>
<div class="small_text" align="center">
Sie haben bereits einen Account?
<br>
<a href="login.php">Anmelden</a><br>
<br>
Probleme bei der Registrierung?<br>
<a href="#" onclick="openContactModal(); return false;">Admin kontaktieren</a>
</div>
</div><!-- EOD: login_content -->
</div><!-- EOD: login_panel -->
<label for="first_name">Vorname</label>
<div class="item"><input class="login_field" type="text" id="first_name" name="first_name" value="<?= authorization_html($form['first_name']) ?>" maxlength="100" required autocomplete="given-name"></div>
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/projects/_central/php/footer.php'; ?>
<label for="last_name">Nachname</label>
<div class="item"><input class="login_field" type="text" id="last_name" name="last_name" value="<?= authorization_html($form['last_name']) ?>" maxlength="100" required autocomplete="family-name"></div>
<label for="email">E-Mailadresse</label>
<div class="item"><input class="login_field" type="email" id="email" name="email" value="<?= authorization_html($form['email']) ?>" maxlength="254" required autocomplete="email"></div>
<label for="phone">Telefonnummer</label>
<div class="item">
<div style="display:flex;align-items:stretch;width:100%;max-width:100%;margin-bottom:10px;box-sizing:border-box;">
<div class="input-prefix" style="border-radius:0;border:1px solid var(--gray-300);border-right:none;margin:0;padding:14px 12px;font-weight:500;box-shadow:none;width:auto;background:var(--gray-200);color:var(--gray-700);display:flex;align-items:center;flex-shrink:0;">+49</div>
<input class="login_field" type="tel" id="phone" name="phone" value="<?= authorization_html($form['phone']) ?>" maxlength="20" style="border-radius:0;border-left:0;margin:0;flex:1;width:auto;min-width:0;" required autocomplete="tel-national">
</div>
</div>
<label for="password">Passwort</label>
<div class="item"><input class="login_field" type="password" id="password" name="password" required autocomplete="new-password"></div>
<label for="password_confirmation">Passwort wiederholen</label>
<div class="item"><input class="login_field" type="password" id="password_confirmation" name="password_confirmation" required autocomplete="new-password"></div>
<input class="login_button" type="submit" value="Registrieren">
</form>
<div class="small_text" align="center">
Sie haben bereits einen Account?<br>
<a href="login.php">Anmelden</a><br><br>
Probleme bei der Registrierung?<br>
<a href="#" onclick="openContactModal(); return false;">Admin kontaktieren</a>
</div>
</div>
</div>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/intranet_repo/projects/_central/php/footer.php'; ?>
</body>
</html>
</html>