Use POST to api token refresh

This commit is contained in:
Paweł Jastrzębski 2022-08-29 08:44:17 +02:00
parent b286c80754
commit 5e48e2dcf5
2 changed files with 5 additions and 4 deletions

View File

@ -16,9 +16,10 @@
<p class="label mb-1">Personal API token</p>
<div class="flex justify-between">
<span class='chip ~info !normal'>{{request.user.api_token}}</span>
<a class="href" href="{% url 'dashboard:api_token_refresh' %}">
<button type="submit" class="button ~neutral @high">Refresh token</button>
</a>
<form method="POST" action="{% url 'dashboard:api_token_refresh' %}">
{% csrf_token %}
<button type="submit" name="action" class="button ~neutral @high">{% trans "Refresh token" %}</button>
</form>
</div>
<p class="support mt-1">To learn more about the API, see our <a href="https://github.com/milesmcc/shynet/blob/master/GUIDE.md#api">API guide</a>.</p>
</div>

View File

@ -158,7 +158,7 @@ class ServiceSessionView(LoginRequiredMixin, PermissionRequiredMixin, DetailView
class RefreshApiTokenView(LoginRequiredMixin, View):
def get(self, request):
def post(self, request):
request.user.api_token = _default_api_token()
request.user.save()
return redirect('account_change_password')