From 39b3519266c6e72647e85259c304ce67b005d914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20M=C3=BCnch?= Date: Tue, 23 Jun 2020 11:13:24 +0000 Subject: [PATCH] fix login/logout paths, reload page instead fancy css because the csrf token gets renewed after every login/logout --- coinmanager/coinc/static/coinc/main.js | 33 ++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/coinmanager/coinc/static/coinc/main.js b/coinmanager/coinc/static/coinc/main.js index f12b186..b0336c2 100644 --- a/coinmanager/coinc/static/coinc/main.js +++ b/coinmanager/coinc/static/coinc/main.js @@ -238,13 +238,15 @@ $(document).ready(function() { }); function login(args, form_data) { + $('body').css('cursor', 'progress'); $.ajax({ type: 'POST', - url: '/coinc/accounts/login/', + 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'); + detach('#login'); //$('button#do_login').addClass('d-none'); //$('button#begin_edit').removeClass('d-none'); //$('button#do_logout').removeClass('d-none'); @@ -255,19 +257,20 @@ $(document).ready(function() { // logout $('#do_logout').click(function() { - let data = { csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val() }; - $.ajax({ - type: 'POST', - data: data, - url: '/coinc/accounts/logout/', - success: function(response) { - window.open(window.location.href, '_self'); - //detach('login'); - //$('button#do_logout').addClass('d-none'); - //$('button#begin_edit').addClass('d-none'); - //$('button#do_login').removeClass('d-none'); - } - }); + $('body').css('cursor', 'progress'); + let data = { csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val() }; + $.ajax({ + type: 'POST', + data: 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'); + //$('button#do_login').removeClass('d-none'); + } + }); });