Files
NoN-Site/nonpacks/templates/profiles/settings.html
T

60 lines
2.0 KiB
HTML

{% extends 'base.html' %}
{% block title %}Settings - Packs{% endblock %}
{% block content %}
<h1>Settings</h1>
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
<h2>API Tokens</h2>
<p>Tokens let non-browser clients (like a Fabric mod) access the API and download packs.</p>
<p class="token-hint">
Send credentials as <code>Authorization: Bearer &lt;username&gt; &lt;token&gt;</code>,
e.g. <code>Authorization: Bearer {{ request.user.username }} &lt;token&gt;</code>
</p>
<form method="post" action="{% url 'profiles:token_create' %}" class="token-create">
{% csrf_token %}
<input type="text" name="label" placeholder="Token label (e.g. Fabric updater)" required>
<button type="submit">Create token</button>
</form>
{% if tokens %}
<table class="token-table">
<thead>
<tr>
<th>Label</th>
<th>Credential</th>
<th>Created</th>
<th>Last used</th>
<th></th>
</tr>
</thead>
<tbody>
{% for token in tokens %}
<tr>
<td>{{ token.label }}</td>
<td><code>{{ request.user.username }} {{ token.token }}</code></td>
<td>{{ token.created_at }}</td>
<td>{{ token.last_used|default:"never" }}</td>
<td>
<form method="post" action="{% url 'profiles:token_delete' token.id %}">
{% csrf_token %}
<button type="submit">Revoke</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No tokens yet.</p>
{% endif %}
{% endblock %}