M3 Passwort-Reset und E-Mail-Verifikation ergänzen
- Auth-Token-Tabelle mit gehashten Single-Use-Tokens einführen - Passwort-Reset und E-Mail-Verifikation als Dev-Flow bauen - Token-Flow-Test, Smoke-Abdeckung und M3-Dokumentation aktualisieren
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/functions.php';
|
||||
|
||||
$pdo = app_db_pdo();
|
||||
$user = saas_require_login();
|
||||
$errors = [];
|
||||
$message = '';
|
||||
$verificationLink = null;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
app_require_csrf();
|
||||
$result = saas_request_email_verification($pdo, (int)$user['user_id'], (int)$user['tenant_id']);
|
||||
|
||||
if ($result['ok']) {
|
||||
if (!empty($result['already_verified'])) {
|
||||
$message = 'Die E-Mail-Adresse ist bereits bestaetigt.';
|
||||
} else {
|
||||
$message = 'Der Verifizierungslink wurde vorbereitet.';
|
||||
if (saas_should_show_auth_links() && !empty($result['token'])) {
|
||||
$verificationLink = 'email-verifizieren.php?token=' . urlencode((string)$result['token']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$errors = $result['errors'];
|
||||
}
|
||||
}
|
||||
|
||||
include 'header.php';
|
||||
include 'headerline.php';
|
||||
include 'nav.php';
|
||||
?>
|
||||
|
||||
<section id="banner">
|
||||
<div class="content">
|
||||
<h2>E-Mail verifizieren</h2>
|
||||
|
||||
<?php if ($message !== ''): ?>
|
||||
<div class="hint-box success">
|
||||
<p><?php echo saas_html($message); ?></p>
|
||||
<?php if ($verificationLink !== null): ?>
|
||||
<p><a href="<?php echo saas_html($verificationLink); ?>">Dev-Link zur Verifizierung</a></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($errors !== []): ?>
|
||||
<div class="hint-box error">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo saas_html($error); ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="email-verifikation-senden.php">
|
||||
<?php echo app_csrf_field(); ?>
|
||||
<p><?php echo saas_html($user['email']); ?></p>
|
||||
<ul class="actions">
|
||||
<li><button type="submit">Verifizierungslink vorbereiten</button></li>
|
||||
<li><a href="konto.php" class="button alt">Zurueck</a></li>
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
Reference in New Issue
Block a user