<?php require_once __DIR__.'/../app/bootstrap.php'; require_once __DIR__.'/_layout.php'; $user=require_login($pdo); csrf_check(); $msg=''; $error=''; if($_SERVER['REQUEST_METHOD']==='POST'){ $current=$_POST['current_password']??''; $new=$_POST['new_password']??''; $confirm=$_POST['confirm_password']??''; if($new!==$confirm){$error='Die neuen Passwörter stimmen nicht überein.';} elseif(!password_is_strong($new)){$error=function_exists('password_requirements_text') ? password_requirements_text() : 'Das neue Passwort ist zu schwach.';} elseif(change_password($pdo,(int)$user['id'],$current,$new)){$msg='Passwort wurde geändert.';} else {$error='Passwort konnte nicht geändert werden. Bitte aktuelles Passwort prüfen.';}} page_header('Passwort ändern'); ?>
<?php if($msg): ?><p class="notice ok"><?= e($msg) ?></p><?php endif; ?><?php if($error): ?><p class="notice"><?= e($error) ?></p><?php endif; ?>
<form method="post" class="card formgrid"><input type="hidden" name="csrf" value="<?= e(csrf_token()) ?>"><label>Aktuelles Passwort<input name="current_password" type="password" required autocomplete="current-password"></label><label>Neues Passwort<input name="new_password" type="password" minlength="12" required autocomplete="new-password"></label><label>Neues Passwort wiederholen<input name="confirm_password" type="password" minlength="12" required autocomplete="new-password"></label><button class="btn">Passwort speichern</button></form><?php page_footer(); ?>
