fix login/logout paths, reload page instead fancy css because the csrf token gets renewed after every login/logout

This commit is contained in:
Moritz Münch 2020-06-23 11:13:24 +00:00
parent fb2a1cd4b6
commit 39b3519266

View File

@ -238,13 +238,15 @@ $(document).ready(function() {
}); });
function login(args, form_data) { function login(args, form_data) {
$('body').css('cursor', 'progress');
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '/coinc/accounts/login/', url: './accounts/login/',
data: form_data, data: form_data,
success: function(response) { 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'); window.open(window.location.href, '_self');
//detach('#login'); detach('#login');
//$('button#do_login').addClass('d-none'); //$('button#do_login').addClass('d-none');
//$('button#begin_edit').removeClass('d-none'); //$('button#begin_edit').removeClass('d-none');
//$('button#do_logout').removeClass('d-none'); //$('button#do_logout').removeClass('d-none');
@ -255,14 +257,15 @@ $(document).ready(function() {
// logout // logout
$('#do_logout').click(function() { $('#do_logout').click(function() {
$('body').css('cursor', 'progress');
let data = { csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val() }; let data = { csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val() };
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
data: data, data: data,
url: '/coinc/accounts/logout/', url: './accounts/logout/',
success: function(response) { success: function(response) {
window.open(window.location.href, '_self'); // TODO nötig, da der csrf-token nach dem anmelden geändert wird und ich mir erst den neuen holen muss.
//detach('login'); window.open('./', '_self');
//$('button#do_logout').addClass('d-none'); //$('button#do_logout').addClass('d-none');
//$('button#begin_edit').addClass('d-none'); //$('button#begin_edit').addClass('d-none');
//$('button#do_login').removeClass('d-none'); //$('button#do_login').removeClass('d-none');