Dissuade non-superusers from creating API tokens via the admin view

This commit is contained in:
Jeremy Stretch 2024-04-19 14:05:45 -04:00
parent 3551f3e021
commit 824d66a54c
2 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,9 @@
{% extends 'generic/object_edit.html' %}
{% load i18n %}
{% block content %}
{% if not request.user.is_superuser %}
{% include 'inc/alerts/warning.html' with title="Creating API Tokens" message="Non-superusers should generally create and modify API tokens under their user profile." %}
{% endif %}
{{ block.super }}
{% endblock %}

View File

@ -28,6 +28,7 @@ class TokenView(generic.ObjectView):
class TokenEditView(generic.ObjectEditView):
queryset = Token.objects.all()
form = forms.TokenForm
template_name = 'users/token_edit.html'
@register_model_view(Token, 'delete')