pws reset

This commit is contained in:
Priec
2026-08-11 08:40:49 +02:00
parent 8ddabf78f6
commit 71106a04cb
20 changed files with 323 additions and 136 deletions

View File

@@ -13,7 +13,7 @@
<div class="actions"><a href="/admin">← Admin panel</a></div>
</section>
{% if page.updated %}<p class="notice">Authorization updated. The current session remains valid and all subsequent requests use the new policy.</p>{% endif %}
{% if page.updated %}<p class="notice">Administration updated. The current session remains valid and all subsequent requests use the new state.</p>{% endif %}
{% if page.can_manage_roles %}
<section class="panel">
@@ -84,7 +84,7 @@
<section class="panel">
<h2>Users</h2>
<table class="builder-table">
<thead><tr><th>Username</th><th>Email</th><th>Current role</th><th>Assign role</th></tr></thead>
<thead><tr><th>Username</th><th>Email</th><th>Current role</th><th>Assign role</th><th>Reset password</th></tr></thead>
<tbody>{% for user in page.users %}<tr>
<td>{{ user.username }}</td><td>{{ user.email }}</td><td>{{ user.role }}</td>
<td><form hx-post="/admin/permissions/users/role" hx-target="#permission-status" class="actions">
@@ -92,6 +92,12 @@
<select name="role">{% for role in page.assignable_roles() %}<option value="{{ role.name }}" {% if user.role == role.name %}selected{% endif %}>{{ role.name }}</option>{% endfor %}</select>
<button type="submit">Assign</button>
</form></td>
<td>{% if page.can_reset_password(user) %}<form hx-post="/admin/permissions/users/password" hx-target="#permission-status" class="actions">
<input type="hidden" name="username" value="{{ user.username }}">
<input name="new_password" type="password" autocomplete="new-password" placeholder="New password" required>
<input name="new_password_confirmation" type="password" autocomplete="new-password" placeholder="Confirm password" required>
<button type="submit">Reset</button>
</form>{% endif %}</td>
</tr>{% endfor %}</tbody>
</table>
</section>

View File

@@ -1,20 +0,0 @@
{% extends "ui/base.html" %}
{% block title %}Claim administrator{% endblock %}
{% block content %}
<main class="login-main">
<form class="login-card" hx-post="/initial-password" hx-target="#initial-password-status" hx-swap="innerHTML" hx-disabled-elt="button" novalidate>
<h1>Claim bootstrap administrator</h1>
<p class="hint">This works once for a fresh passwordless <code>admin</code> or <code>superadmin</code> account.</p>
<label>Account
<select name="username"><option value="admin">admin</option><option value="superadmin">superadmin</option></select>
</label>
<label>Password<input name="password" type="password" autocomplete="new-password" required></label>
<label>Confirm password<input name="password_confirmation" type="password" autocomplete="new-password" required></label>
<button type="submit">Set initial password</button>
<p class="login-alt"><a href="/login">Back to sign in</a></p>
<div id="initial-password-status" aria-live="polite"></div>
</form>
</main>
{% endblock %}

View File

@@ -8,12 +8,10 @@
<form class="login-card" hx-post="/login" hx-target="#login-status" hx-swap="innerHTML"
hx-disabled-elt="button" novalidate>
<h1>Sign in</h1>
{% if initial_password_set %}<p class="notice">The initial password was set. You can sign in now.</p>{% endif %}
<label>Username or email<input name="identifier" autocomplete="username"></label>
<label>Password <span>(optional)</span><input name="password" type="password" autocomplete="current-password"></label>
<button type="submit">Login</button>
<p class="login-alt">No account yet? <a href="/register">Register</a></p>
<p class="login-alt">Fresh installation? <a href="/initial-password">Claim a bootstrap administrator</a></p>
<div id="login-status" aria-live="polite"></div>
</form>
</main>

View File

@@ -0,0 +1,17 @@
{% extends "ui/base.html" %}
{% block title %}Change password{% endblock %}
{% block content %}
<main class="login-main">
<form class="login-card" hx-post="/password" hx-target="#password-status" hx-swap="innerHTML" hx-disabled-elt="button" novalidate>
<h1>Change password</h1>
<p class="hint">For a freshly seeded admin or superadmin account, leave the current password empty.</p>
<label>Current password<input name="current_password" type="password" autocomplete="current-password"></label>
<label>New password<input name="new_password" type="password" autocomplete="new-password" required></label>
<label>Confirm new password<input name="new_password_confirmation" type="password" autocomplete="new-password" required></label>
<button type="submit">Change password</button>
<div id="password-status" aria-live="polite"></div>
</form>
</main>
{% endblock %}