rinkplanner/hub/views/account.php
torsten 055a2919c3 feat: Kür-Hub mit Einladungen, Uploads und API
- PHP-App unter hub/ für rinkplanner-hub.programmschmiede.de
- MariaDB-Schema, Argon2id, Sessions, CSRF und Ratenbegrenzung
- Einladungscodes, Admin-Bereich und Kür-Pakete mit Audiodatei
- JSON-API v1 mit Bearer-Tokens für die Godot-App
- Deployment und Erstinstallation über tools/deploy_hub.sh
- Doku und Credentials-Vorlage ergänzt
2026-11-11 13:14:26 +01:00

77 lines
3.5 KiB
PHP

<?php /** @var array $tokens */ ?>
<?php $user = auth_user(); ?>
<section class="page-head">
<div>
<h1>Konto</h1>
<p class="muted"><?= e($user['username']) ?> · <?= e($user['role'] === 'admin' ? 'Administrator' : 'Beta-Nutzer') ?></p>
</div>
</section>
<?php if ($user['must_change_password'] === 1): ?>
<div class="flash flash-info">Bitte ein neues Passwort setzen, bevor du den Hub weiter nutzt.</div>
<?php endif; ?>
<div class="columns">
<section class="panel">
<h2>Passwort ändern</h2>
<form method="post" action="<?= e(url('/account/password')) ?>" class="stack">
<?= csrf_field() ?>
<label>
Aktuelles Passwort
<input type="password" name="current_password" autocomplete="current-password" required>
</label>
<label>
Neues Passwort
<input type="password" name="password" autocomplete="new-password" required>
<span class="hint">Mindestens 10 Zeichen.</span>
</label>
<label>
Neues Passwort wiederholen
<input type="password" name="password_repeat" autocomplete="new-password" required>
</label>
<button class="primary" type="submit">Passwort speichern</button>
</form>
</section>
<section class="panel">
<h2>API-Tokens</h2>
<p class="muted">Für die Godot-App. Ein Token ersetzt Benutzername und Passwort im Client und lässt sich jederzeit widerrufen.</p>
<form method="post" action="<?= e(url('/account/tokens')) ?>" class="inline-form">
<?= csrf_field() ?>
<input type="text" name="name" maxlength="64" placeholder="Name, z. B. Büro-PC" required>
<button type="submit">Token erzeugen</button>
</form>
<?php if ($tokens): ?>
<div class="table-wrap">
<table class="list compact">
<thead>
<tr><th>Name</th><th>Prefix</th><th>Erstellt</th><th>Zuletzt</th><th>Status</th><th></th></tr>
</thead>
<tbody>
<?php foreach ($tokens as $token): ?>
<tr>
<td><?= e($token['name']) ?></td>
<td><code><?= e($token['prefix']) ?>…</code></td>
<td><?= e(fmt_dt($token['created_at'])) ?></td>
<td><?= e(fmt_dt($token['last_used_at'])) ?></td>
<td><?= $token['revoked_at'] !== null ? 'widerrufen' : 'aktiv' ?></td>
<td>
<?php if ($token['revoked_at'] === null): ?>
<form class="inline" method="post" action="<?= e(url('/account/tokens/revoke')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="token_id" value="<?= (int) $token['id'] ?>">
<button class="link-button danger" type="submit">widerrufen</button>
</form>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<p class="muted small">Noch kein Token erzeugt.</p>
<?php endif; ?>
</section>
</div>