80 lines
2.9 KiB
PHP
80 lines
2.9 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;
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$result = $service->complete(
|
|
$token,
|
|
(string) ($_POST['password'] ?? ''),
|
|
(string) ($_POST['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" required>
|
|
</label>
|
|
|
|
<label class="login-field">
|
|
<span>Neues Passwort wiederholen</span>
|
|
<input type="password" name="password_confirm" 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>
|