Files
desktop/public/auth/reset-password/index.php
Lars Gebhardt-Kusche 5408a2bb89
All checks were successful
Deploy / deploy-staging (push) Successful in 26s
Deploy / deploy-production (push) Has been skipped
adasd
2026-06-15 21:36:36 +02:00

89 lines
3.2 KiB
PHP

<?php
declare(strict_types=1);
require_once dirname(__DIR__, 3) . '/src/App/bootstrap.php';
use App\ConfigLoader;
use App\PasswordResetService;
$projectRoot = dirname(__DIR__, 3);
$service = new PasswordResetService($projectRoot, ConfigLoader::load($projectRoot, 'registration'));
$token = trim((string) ($_GET['token'] ?? $_POST['token'] ?? ''));
$record = $service->validate($token);
$message = null;
$error = null;
$form = [
'password' => '',
'password_confirm' => '',
];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$form = [
'password' => (string) ($_POST['password'] ?? ''),
'password_confirm' => (string) ($_POST['password_confirm'] ?? ''),
];
$result = $service->complete(
$token,
$form['password'],
$form['password_confirm']
);
if ($result['success'] ?? false) {
$message = (string) ($result['message'] ?? '');
$record = null;
} else {
$error = (string) ($result['message'] ?? '');
}
}
?><!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Passwort zurücksetzen</title>
<link rel="stylesheet" href="/assets/auth/login.css">
</head>
<body>
<main class="login-shell">
<section class="login-panel">
<div class="login-panel-top">
<p class="login-kicker">Kusche.Berlin</p>
<h1>Passwort zurücksetzen</h1>
<p class="login-copy">Der Link ist 8 Stunden gültig und setzt sowohl LDAP- als auch Samba-Passwort neu.</p>
</div>
<?php if ($message !== null): ?>
<div class="login-notice login-notice-success"><p><?= htmlspecialchars($message, ENT_QUOTES) ?></p></div>
<?php endif; ?>
<?php if ($error !== null): ?>
<div class="login-notice login-notice-error"><p><?= htmlspecialchars($error, ENT_QUOTES) ?></p></div>
<?php endif; ?>
<?php if ($record !== null): ?>
<form class="login-form" method="post" action="/auth/reset-password/">
<input type="hidden" name="token" value="<?= htmlspecialchars($token, ENT_QUOTES) ?>">
<label class="login-field">
<span>Neues Passwort</span>
<input type="password" name="password" value="<?= htmlspecialchars($form['password'], ENT_QUOTES) ?>" required>
</label>
<label class="login-field">
<span>Neues Passwort wiederholen</span>
<input type="password" name="password_confirm" value="<?= htmlspecialchars($form['password_confirm'], ENT_QUOTES) ?>" required>
</label>
<div class="login-actions">
<button class="login-button login-button-primary" type="submit">Passwort zurücksetzen</button>
</div>
</form>
<?php else: ?>
<div class="login-notice login-notice-info"><p>Der Token ist ungültig oder bereits verwendet.</p></div>
<?php endif; ?>
</section>
</main>
</body>
</html>