diff --git a/coinmanager/coinc/static/coinc/main.js b/coinmanager/coinc/static/coinc/main.js index aa0a603..2d4878b 100644 --- a/coinmanager/coinc/static/coinc/main.js +++ b/coinmanager/coinc/static/coinc/main.js @@ -1,6 +1,6 @@ /* - Copyright (C) 2020 willipink.eu + Copyright (C) 2020-2022 willipink.eu Author Moritz Münch moritzmuench@mailbox.org This program is free software: you can redistribute it and/or modify @@ -239,12 +239,12 @@ $(document).ready(function() { function login(args, form_data) { $('body').css('cursor', 'progress'); + form_data['csrfmiddlewaretoken'] = cookie.get('csrftoken'); $.ajax({ type: 'POST', url: './accounts/login/', data: form_data, success: function(response) { - // TODO nötig, da der csrf-token nach dem anmelden geändert wird und ich mir erst den neuen holen muss. window.open(window.location.href, '_self'); detach('#login'); //$('button#do_login').addClass('d-none'); @@ -258,13 +258,12 @@ $(document).ready(function() { // logout $('#do_logout').click(function() { $('body').css('cursor', 'progress'); - let data = { csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val() }; + let form_data = {'csrfmiddlewaretoken': cookie.get('csrftoken') } $.ajax({ type: 'POST', - data: data, + data: form_data, url: './accounts/logout/', success: function(response) { - // TODO nötig, da der csrf-token nach dem anmelden geändert wird und ich mir erst den neuen holen muss. window.open('./', '_self'); //$('button#do_logout').addClass('d-none'); //$('button#begin_edit').addClass('d-none'); @@ -289,7 +288,6 @@ $(document).ready(function() { $(this).click(function() { save_settings(); - let csrf_token = $('input[name=csrfmiddlewaretoken]').val(); let value = Number($(this).attr('value')); let year = Number($(this).parent('tr').attr('name')); year += (year == 99) ? 1900 : 2000; // TODO fix this before the end of 2098 @@ -302,7 +300,6 @@ $(document).ready(function() { if (settings['exists'] === false) { circulation = 0; } let data = { - csrfmiddlewaretoken: csrf_token, value: value, year: year, country: country, @@ -337,6 +334,7 @@ $(document).ready(function() { if (response) { data['name'] = response['name'].trim().substring(0, 79); } $(td).css('cursor', 'progress'); + data['csrfmiddlewaretoken'] = cookie.get('csrftoken'); $.ajax({ type: 'POST', diff --git a/coinmanager/coinc/templates/coinc/controlbar.html b/coinmanager/coinc/templates/coinc/controlbar.html index d46291e..c7ec19d 100644 --- a/coinmanager/coinc/templates/coinc/controlbar.html +++ b/coinmanager/coinc/templates/coinc/controlbar.html @@ -1,6 +1,3 @@ -{% load cache %} -{% csrf_token %} -{% cache None controlbar user %} @@ -115,7 +112,6 @@ -{% endcache %} {% if not user.is_authenticated %}