diff --git a/tubearchivist/home/templates/home/settings.html b/tubearchivist/home/templates/home/settings.html
index 83829f3..740ca40 100644
--- a/tubearchivist/home/templates/home/settings.html
+++ b/tubearchivist/home/templates/home/settings.html
@@ -120,6 +120,7 @@
API token:
diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py
index a0cac87..660ec73 100644
--- a/tubearchivist/home/views.py
+++ b/tubearchivist/home/views.py
@@ -715,7 +715,6 @@ class SettingsView(View):
"""get existing or create new token of user"""
# pylint: disable=no-member
token = Token.objects.get_or_create(user=request.user)[0]
- print(token)
return token
@staticmethod
@@ -758,6 +757,11 @@ def process(request):
if request.method == "POST":
current_user = request.user.id
post_dict = json.loads(request.body.decode())
+ if post_dict.get("reset-token"):
+ print("revoke API token")
+ request.user.auth_token.delete()
+ return JsonResponse({"success": True})
+
post_handler = PostData(post_dict, current_user)
if post_handler.to_exec:
task_result = post_handler.run_task()
diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js
index db91621..22cfd56 100644
--- a/tubearchivist/static/script.js
+++ b/tubearchivist/static/script.js
@@ -235,6 +235,14 @@ function findPlaylists(button) {
}, 500);
}
+function resetToken() {
+ var payload = JSON.stringify({'reset-token': true});
+ sendPost(payload);
+ var message = document.createElement("p");
+ message.innerText = "Token revoked";
+ document.getElementById("text-reveal").replaceWith(message);
+}
+
// delete from file system
function deleteConfirm() {
to_show = document.getElementById("delete-button");