<?php require_once __DIR__.'/../app/bootstrap.php'; csrf_check(); $token=$_GET['token']??$_POST['token']??''; $user=find_user_by_reset_token($pdo,$token); $error=''; $done=false; if($_SERVER['REQUEST_METHOD']==='POST'){ $new=$_POST['new_password']??''; $confirm=$_POST['confirm_password']??''; if($new!==$confirm){$error='Die Passwörter stimmen nicht überein.';} elseif(!password_is_strong($new)){$error='Das Passwort braucht mindestens 12 Zeichen.';} elseif(reset_password($pdo,$token,$new)){$done=true;} else {$error='Der Reset-Link ist ungültig oder abgelaufen.';} } ?>
<!doctype html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Passwort zurücksetzen · KuhRator</title><link rel="stylesheet" href="../public/assets/style.css"><script src="../public/assets/admin.js" defer></script></head><body><main class="login"><section class="card formgrid"><h1>Passwort zurücksetzen</h1><?php if($done): ?><p class="notice ok">Passwort wurde gespeichert.</p><p><a class="btn" href="login.php">Zum Login</a></p><?php elseif(!$user): ?><p class="notice">Der Reset-Link ist ungültig oder abgelaufen.</p><p><a href="forgot-password.php">Neuen Link anfordern</a></p><?php else: ?><?php if($error): ?><p class="notice"><?= e($error) ?></p><?php endif; ?><form method="post" class="formgrid"><input type="hidden" name="csrf" value="<?= e(csrf_token()) ?>"><input type="hidden" name="token" value="<?= e($token) ?>"><label>Neues Passwort<span class="password-field"><input name="new_password" type="password" minlength="12" required autocomplete="new-password" data-password-toggle><button type="button" class="password-toggle" data-password-toggle-button aria-label="Passwort anzeigen" aria-pressed="false"><span class="eye-open" aria-hidden="true">&#128065;</span><span class="eye-closed" aria-hidden="true">&#128584;</span></button></span></label><label>Neues Passwort wiederholen<span class="password-field"><input name="confirm_password" type="password" minlength="12" required autocomplete="new-password" data-password-toggle><button type="button" class="password-toggle" data-password-toggle-button aria-label="Passwort anzeigen" aria-pressed="false"><span class="eye-open" aria-hidden="true">&#128065;</span><span class="eye-closed" aria-hidden="true">&#128584;</span></button></span></label><button class="btn">Passwort speichern</button></form><?php endif; ?></section></main></body></html>
