75 lines
2.6 KiB
HTML
75 lines
2.6 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block content %}
|
|
<section class="hero" data-test="users-page">
|
|
<p class="eyebrow">Admin</p>
|
|
<h1>User Management</h1>
|
|
<p class="lede">Admin-only controls for account creation, activation, and password resets.</p>
|
|
</section>
|
|
|
|
<section class="sandbox" data-test="users-create-card">
|
|
<h2>Create User</h2>
|
|
<form method="post" action="/users" class="stack-form">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
|
<label for="email">Email</label>
|
|
<input id="email" name="email" type="email" value="{{ form_email | default('') }}" required>
|
|
<label for="password">Temporary Password</label>
|
|
<input id="password" name="password" type="password" required>
|
|
<label class="checkbox-row" for="is_admin">
|
|
<input id="is_admin" name="is_admin" type="checkbox" {% if form_is_admin %}checked{% endif %}>
|
|
<span>Admin account</span>
|
|
</label>
|
|
<button type="submit" data-loading-text="Creating...">Create User</button>
|
|
</form>
|
|
</section>
|
|
|
|
<section class="sandbox" data-test="users-list-card">
|
|
<h2>Users</h2>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Email</th>
|
|
<th>Role</th>
|
|
<th>Status</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for user in users %}
|
|
<tr>
|
|
<td>{{ user.email }}</td>
|
|
<td>
|
|
{% if user.is_admin %}
|
|
<span class="badge ok">admin</span>
|
|
{% else %}
|
|
<span class="badge">user</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if user.is_active %}
|
|
<span class="badge ok">active</span>
|
|
{% else %}
|
|
<span class="badge warn">inactive</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<div class="inline-actions">
|
|
<form method="post" action="/users/{{ user.id }}/toggle-active">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
|
<button type="submit" data-loading-text="Saving..." {% if user.id == current_user_id and user.is_active %}disabled{% endif %}>
|
|
{% if user.is_active %}Deactivate{% else %}Activate{% endif %}
|
|
</button>
|
|
</form>
|
|
<form method="post" action="/users/{{ user.id }}/reset-password" class="inline-reset-form">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
|
<input name="new_password" type="password" placeholder="New password" minlength="8" required>
|
|
<button type="submit" data-loading-text="Resetting...">Reset Password</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
{% endblock %}
|