daybook/templates/artifacts/settings_users.html
peter edacb86800 Add admin-only Settings -> Users page for creating accounts
Peter needed a second user for throwaway testing without going through
Django admin each time. Superusers now get a "Users" tab in Settings
(hidden for regular users) with a create-user form and a list of existing
accounts. New users are regular (non-staff, non-superuser) by default, with
an optional "Grant admin access" checkbox; creating one immediately issues
their API token and displays it once, since that's the credential an agent
account needs and a human account can otherwise regenerate for themselves
later from their own Settings -> Account.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-02 12:33:38 +01:00

31 lines
1.2 KiB
HTML

{% extends "artifacts/settings_base.html" %}
{% block settings_content %}
<h2>Users</h2>
{% if created_token %}
<p><strong>API token for {{ created_user.username }}</strong> — shown once, copy it now:</p>
<p><code class="token-value">{{ created_token.key }}</code></p>
{% endif %}
<h3>Add User</h3>
<p>New users are regular accounts by default — they can log in and use their own token, but cannot reach Django admin unless you grant admin access below.</p>
<form method="post">
{% csrf_token %}
<p><label>Username<br><input type="text" name="username" required autocomplete="off"></label></p>
<p><label>Password<br><input type="password" name="password" required autocomplete="new-password"></label></p>
<p><label><input type="checkbox" name="is_superuser"> Grant admin access</label></p>
<button type="submit">Create User</button>
</form>
<h3>Existing Users</h3>
<ul class="storage-facts">
{% for user in users %}
<li>
{{ user.username }}{% if user == request.user %} (you){% endif %}
{% if user.is_superuser %} &mdash; admin{% endif %}
{% if not user.is_active %} &mdash; disabled{% endif %}
</li>
{% endfor %}
</ul>
{% endblock %}