summaryrefslogtreecommitdiffstats
path: root/templates/accounts/manage.html
blob: e7c9b2f52f1a5661cc08ef1af536f200ea73c207 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{% extends "base.html" %}
{% block content %}
<h1>Account Management</h1>

{% if let Some(msg) = message %}
<div class="flash flash-ok">{{ msg }}</div>
{% endif %}

<div class="card">
    <h3>Change My Password</h3>
    <form action="/accounts/change-own-password" method="post" class="form-row">
        <input type="password" name="current_password" placeholder="Current password" required>
        <input type="password" name="new_password" placeholder="New password" required minlength="4">
        <button type="submit" class="btn-ok">Update</button>
    </form>
</div>

<div class="card">
    <h3>Create Account</h3>
    <form action="/accounts/create" method="post" class="form-row">
        <input type="text" name="username" placeholder="Username" required>
        <input type="password" name="password" placeholder="Password" required>
        <label>
            <input type="checkbox" name="is_superuser"> Superuser
        </label>
        <button type="submit" class="btn-ok">Create</button>
    </form>
</div>

<div class="card">
    <h3>Existing Accounts</h3>
    <table class="table">
        <thead>
            <tr>
                <th>Username</th>
                <th>Role</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
        {% for acct in accounts %}
            <tr>
                <td>{{ acct.username }}</td>
                <td>
                    {% if acct.is_superuser %}
                    <span class="tag tag-admin">Superuser</span>
                    {% else %}
                    <span class="tag">User</span>
                    {% endif %}
                </td>
                <td>
                    <div class="actions" style="gap:0.25rem">
                        <form action="/accounts/set-password" method="post" style="display:inline">
                            <input type="hidden" name="id" value="{{ acct.id }}">
                            <input type="password" name="new_password" placeholder="New password" required minlength="4" style="width:140px;padding:0.25rem 0.5rem;font-size:0.8rem">
                            <button type="submit" class="btn-sm">Set</button>
                        </form>
                        <form action="/accounts/delete" method="post" style="display:inline"
                              onsubmit="return confirm('Delete account {{ acct.username }}?')">
                            <input type="hidden" name="id" value="{{ acct.id }}">
                            <button type="submit" class="btn-sm btn-danger">Delete</button>
                        </form>
                    </div>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}