Open registration let anyone with the URL create an account. Two
changes address that:
- REGISTRATION_CODE (.env, optional): when set, registration requires
entering it correctly. Empty/unset keeps registration open, so
existing installs are unaffected until configured.
- is_admin flag on User: the first account ever created on an install
becomes admin automatically (existing installs get their oldest
account promoted via the startup migration, so nobody is locked
out of user management after upgrading).
Admins get a new "Benutzerverwaltung" panel in Einstellungen listing
every account (email, link/prompt counts, join date) with a delete
button per account — deleting cascades to that user's links and
prompts via the existing relationship cascade. Deleting your own
account through this page is blocked (redirects with an error) to
avoid accidental admin lockout. Non-admins get a 403 on the
/settings/users routes.
Also fixes several pre-existing German pluralization bugs found while
writing the new counts ("2 Linke" -> "2 Links", "Kontoen"/"Konton" ->
"Konten") — irregular plurals need a full word swap, not a suffix.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
55 lines
2.4 KiB
HTML
55 lines
2.4 KiB
HTML
{% extends "base.html" %}
|
|
{% import "_icons.html" as icons %}
|
|
{% block title %}Benutzerverwaltung · LinkVault{% endblock %}
|
|
{% block body %}
|
|
{% include "_topbar.html" %}
|
|
|
|
<div class="layout" style="max-width:820px; margin-left:auto; margin-right:auto;">
|
|
<main class="main">
|
|
<div style="display:flex; align-items:center; gap:10px; margin-bottom:4px;">
|
|
<a href="/settings" class="ghost icon-btn" title="Zurück zu den Einstellungen">{{ icons.grid(size=14) }}</a>
|
|
<h1 style="margin:0;">Benutzerverwaltung</h1>
|
|
</div>
|
|
<p class="muted" style="margin-top:0;">
|
|
{{ rows | length }} {{ 'Konto' if rows | length == 1 else 'Konten' }} insgesamt.
|
|
</p>
|
|
|
|
{% if delete_error %}
|
|
<div class="error">{{ delete_error }}</div>
|
|
{% endif %}
|
|
|
|
<div class="panel" style="padding:0; overflow:hidden;">
|
|
{% for row in rows %}
|
|
<div style="display:flex; align-items:center; gap:12px; padding:14px 16px; {% if not loop.last %}border-bottom:1px solid var(--border);{% endif %}">
|
|
<span class="card-avatar" style="--h: {{ row.user.email | texthue }};">
|
|
{{ row.user.email[:1] | upper }}
|
|
</span>
|
|
<div style="flex:1; min-width:0;">
|
|
<div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap;">
|
|
<strong style="overflow:hidden; text-overflow:ellipsis;">{{ row.user.email }}</strong>
|
|
{% if row.user.is_admin %}
|
|
<span class="badge badge-cat">Admin</span>
|
|
{% endif %}
|
|
{% if row.user.id == user.id %}
|
|
<span class="badge badge-tag">Du</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="muted" style="font-size:.8rem; margin-top:2px;">
|
|
{{ row.link_count }} Link{{ '' if row.link_count == 1 else 's' }} ·
|
|
{{ row.prompt_count }} Prompt{{ '' if row.prompt_count == 1 else 's' }} ·
|
|
seit {{ row.user.created_at | datum }}
|
|
</div>
|
|
</div>
|
|
{% if row.user.id != user.id %}
|
|
<form method="post" action="/settings/users/{{ row.user.id }}/delete" style="margin:0;"
|
|
onsubmit="return confirm('Konto {{ row.user.email }} inklusive aller Links und Prompts wirklich löschen?');">
|
|
<button type="submit" class="danger icon-btn" title="Konto löschen">{{ icons.trash() }}</button>
|
|
</form>
|
|
{% endif %}
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</main>
|
|
</div>
|
|
{% endblock %}
|