Files
kaffeekasse-saas/resources/views/auth/reset-confirm.php
T
2026-06-23 00:06:31 +02:00

120 lines
4.7 KiB
PHP

<?php
$scope = trim((string) ($scope ?? old('scope')));
if ($scope === '') {
$scope = trim((string) ($_GET['scope'] ?? ''));
}
$scope = $scope === 'tenant' ? 'tenant' : 'platform';
$tenantSlug = trim((string) ($tenantSlug ?? old('tenant_slug')));
if ($tenantSlug === '') {
$tenantSlug = trim((string) ($_GET['tenantSlug'] ?? $_GET['tenant'] ?? ''));
}
$tenantName = trim((string) ($tenantName ?? old('tenant_name')));
if ($tenantName === '') {
$tenantName = trim((string) ($_GET['tenantName'] ?? ''));
}
if ($tenantName === '' && $tenantSlug !== '') {
$tenantName = 'Kaffeeliste ' . $tenantSlug;
}
if ($tenantName === '') {
$tenantName = 'Kaffeelisten-Zugang';
}
$token = trim((string) ($token ?? old('token')));
$resetToken = isset($resetToken) && is_array($resetToken) ? $resetToken : null;
$hasValidResetToken = $resetToken !== null;
$loginUrl = $scope === 'tenant'
? ($tenantSlug !== '' ? tenant_url($tenantSlug, 'login') : url('/'))
: url('/admin/login');
$requestUrl = url('/password/forgot?scope=' . rawurlencode($scope));
if ($scope === 'tenant' && $tenantSlug !== '') {
$requestUrl .= '&tenantSlug=' . rawurlencode($tenantSlug);
}
if ($scope === 'tenant' && $tenantName !== '') {
$requestUrl .= '&tenantName=' . rawurlencode($tenantName);
}
$resetEmail = trim((string) ($resetToken['email'] ?? ''));
$expiresAt = trim((string) ($resetToken['expires_at'] ?? ''));
require __DIR__ . '/../partials/layout-top.php';
?>
<section class="page-head">
<span class="eyebrow">Passwort erneuern</span>
<h1>Neues Passwort setzen</h1>
<p>
<?= e($hasValidResetToken
? ($scope === 'platform'
? 'Legen Sie hier ein neues Passwort für die Plattformverwaltung fest.'
: 'Legen Sie hier ein neues Passwort für den Zugang von ' . $tenantName . ' fest.')
: 'Hier wird nur mit einem gültigen Link ein neues Passwort gesetzt.') ?>
PINs und Karten bleiben davon unberührt.
</p>
</section>
<div class="two-column">
<?php if ($hasValidResetToken): ?>
<form class="card form-card" method="post" action="<?= e(url(current_path())) ?>">
<?= csrf_field($csrf) ?>
<input type="hidden" name="scope" value="<?= e($scope) ?>">
<?php if ($tenantSlug !== ''): ?>
<input type="hidden" name="tenant_slug" value="<?= e($tenantSlug) ?>">
<?php endif; ?>
<?php if ($scope === 'tenant' && $tenantName !== ''): ?>
<input type="hidden" name="tenant_name" value="<?= e($tenantName) ?>">
<?php endif; ?>
<input type="hidden" name="token" value="<?= e($token) ?>">
<?php if ($resetEmail !== '' || $expiresAt !== ''): ?>
<p class="muted">
<?= e($resetEmail !== '' ? 'Link für ' . $resetEmail . '.' : 'Der Link wurde geprüft.') ?>
<?php if ($expiresAt !== ''): ?>
Gültig bis <?= e($expiresAt) ?>.
<?php endif; ?>
</p>
<?php endif; ?>
<label>
<span>Neues Passwort</span>
<input type="password" name="password" minlength="12" required>
</label>
<label>
<span>Passwort wiederholen</span>
<input type="password" name="password_confirm" minlength="12" required>
</label>
<button class="button button-primary" type="submit">Passwort speichern</button>
<p class="muted">Danach geht es zurück zur Anmeldung.</p>
<p><a class="text-link" href="<?= e($loginUrl) ?>">Zurück zum Login</a></p>
</form>
<?php else: ?>
<div class="card form-card">
<h2>Neuen Link anfordern</h2>
<p class="muted">
<?= e($token === ''
? 'Öffnen Sie den Link aus der E-Mail, um hier ein neues Passwort zu setzen.'
: 'Dieser Link ist ungültig oder abgelaufen. Bitte fordern Sie einen neuen Link an.') ?>
</p>
<p><a class="text-link" href="<?= e($requestUrl) ?>">Neuen Link anfordern</a></p>
<p><a class="text-link" href="<?= e($loginUrl) ?>">Zurück zum Login</a></p>
</div>
<?php endif; ?>
<aside class="card">
<span class="eyebrow">Worauf geachtet wird</span>
<ul class="feature-list">
<li>Mindestens 12 Zeichen für Plattform- und Kaffeelisten-Zugang</li>
<li>Das neue Passwort ersetzt nur den Login, nicht PIN oder Karten</li>
<li>Bei Rückfragen hilft die verantwortliche Person der Kaffeeliste</li>
</ul>
</aside>
</div>
<?php require __DIR__ . '/../partials/layout-bottom.php'; ?>