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>
This commit is contained in:
parent
f2f2a9c96b
commit
edacb86800
7 changed files with 138 additions and 1 deletions
31
templates/artifacts/settings_users.html
Normal file
31
templates/artifacts/settings_users.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{% 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 %} — admin{% endif %}
|
||||
{% if not user.is_active %} — disabled{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue