Files

69 lines
3.0 KiB
HTML

{% extends "base.html" %}
{% block title %}Benutzer{% endblock %}
{% block content %}
<h1>Benutzer</h1>
<section class="card">
<h2>Benutzer anlegen</h2>
<form method="post" action="/users">
{{ csrf_input }}
<label for="new-username">Benutzername</label>
<input id="new-username" name="username" type="text" autocomplete="off" autocapitalize="none" required>
<label for="new-password">Passwort (mindestens {{ min_len }} Zeichen)</label>
<input id="new-password" name="password" type="password" minlength="{{ min_len }}" autocomplete="new-password" required>
<label for="new-role">Rolle</label>
<select id="new-role" name="role">
{% for r in roles %}<option value="{{ r }}" {% if loop.last %}selected{% endif %}>{{ r }}</option>{% endfor %}
</select>
<div class="actions"><button type="submit">Anlegen</button></div>
</form>
</section>
<section class="card">
<h2>Bestehende Benutzer</h2>
<div class="table-wrap">
<table>
<thead><tr><th>Name</th><th>Rolle</th><th>2FA</th><th>Status</th><th>Aktionen</th></tr></thead>
<tbody>
{% for u in users %}
<tr>
<td>{{ u.username }}{% if u.id == user.id %} <span class="badge info">du</span>{% endif %}</td>
<td>
<form method="post" action="/users/{{ u.id }}/role" class="row">
{{ csrf_input }}
<select name="role" aria-label="Rolle von {{ u.username }}">
{% for r in roles %}<option value="{{ r }}" {% if r == u.role %}selected{% endif %}>{{ r }}</option>{% endfor %}
</select>
<button type="submit" class="secondary">Ändern</button>
</form>
</td>
<td>{{ 'ja' if u.has_totp else 'nein' }}</td>
<td><span class="badge {{ 'error' if u.disabled else 'ok' }}">{{ 'gesperrt' if u.disabled else 'aktiv' }}</span></td>
<td>
<form method="post" action="/users/{{ u.id }}/password" class="row">
{{ csrf_input }}
<input name="password" type="password" minlength="{{ min_len }}" autocomplete="new-password"
placeholder="Neues Passwort" aria-label="Neues Passwort für {{ u.username }}" required>
<button type="submit" class="secondary">Passwort setzen</button>
</form>
{% if u.id != user.id %}
<div class="row">
<form method="post" action="/users/{{ u.id }}/disable" class="inline">
{{ csrf_input }}
<input type="hidden" name="disabled" value="{{ '0' if u.disabled else '1' }}">
<button type="submit" class="secondary">{{ 'Entsperren' if u.disabled else 'Sperren' }}</button>
</form>
<form method="post" action="/users/{{ u.id }}/delete" class="inline" data-confirm="Benutzer wirklich löschen?">
{{ csrf_input }}
<button type="submit" class="danger">Löschen</button>
</form>
</div>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
{% endblock %}