diff options
author | Raphael Kabo <raphaelkabo@hey.com> | 2023-10-09 17:24:09 +0100 |
---|---|---|
committer | Raphael Kabo <raphaelkabo@hey.com> | 2023-10-09 17:24:09 +0100 |
commit | dbbb94117c2d6266cfc45a091b4b87012024f788 (patch) | |
tree | ba8eacd0919507a874189f1091a2ec0957c39686 | |
parent | cc6fcb4c405d8cffacbf9b1082abf61e918482fa (diff) |
Fix event token param bug
-rwxr-xr-x | views/event.handlebars | 4 | ||||
-rwxr-xr-x | views/eventgroup.handlebars | 19 |
2 files changed, 14 insertions, 9 deletions
diff --git a/views/event.handlebars b/views/event.handlebars index ae6674a..f4f1a2e 100755 --- a/views/event.handlebars +++ b/views/event.handlebars @@ -423,9 +423,9 @@ window.eventData = {{{ json jsonData }}}; $(this).closest(".comment").find(".replyContainer").slideToggle(); }) $(document).ready(function() { - // Save the editing token from the URL, if it is valid const eventID = $('#eventName').attr('data-event-id'); + const url = new URL(window.location.href); const urlParams = new URLSearchParams(window.location.search); if (urlParams.has('e')) { $.ajax({ @@ -463,6 +463,8 @@ window.eventData = {{{ json jsonData }}}; if (urlParams.has('show_edit')) { $('#editModal').modal('show'); + url.searchParams.delete('show_edit'); + history.replaceState(history.state, '', url.href); } // From https://davidwalsh.name/javascript-download diff --git a/views/eventgroup.handlebars b/views/eventgroup.handlebars index 0643ed6..1d3975a 100755 --- a/views/eventgroup.handlebars +++ b/views/eventgroup.handlebars @@ -229,29 +229,30 @@ window.groupData = {{{ json jsonData }}}; <script> $(document).ready(function() { // Save the editing token from the URL, if it is valid - const eventID = $('#eventName').attr('data-event-id'); + const eventGroupID = window.groupData.id; + const url = new URL(window.location.href); const urlParams = new URLSearchParams(window.location.search); if (urlParams.has('e')) { $.ajax({ type: "POST", - url: `/verifytoken/group/${eventID}`, + url: `/verifytoken/group/${eventGroupID}`, data: { editToken: urlParams.get('e') }, success: function(response, status, xhr) { if (xhr.status === 200) { - addStoredToken(eventID, urlParams.get('e')); + addStoredToken(eventGroupID, urlParams.get('e')); } }, error: function(response, status, xhr) { // The editing token is wrong - remove it - removeStoredToken(eventID); + removeStoredToken(eventGroupID); window.location = window.location.pathname; } }); - } else if (getStoredToken(eventID)) { - const editToken = getStoredToken(eventID); + } else if (getStoredToken(eventGroupID)) { + const editToken = getStoredToken(eventGroupID); $.ajax({ type: "POST", - url: `/verifytoken/group/${eventID}`, + url: `/verifytoken/group/${eventGroupID}`, data: { editToken }, success: function(response, status, xhr) { if (xhr.status === 200) { @@ -260,13 +261,15 @@ window.groupData = {{{ json jsonData }}}; }, error: function(response, status, xhr) { // The editing token is wrong - remove it - removeStoredToken(eventID); + removeStoredToken(eventGroupID); } }); } if (urlParams.has('show_edit')) { $('#editModal').modal('show'); + url.searchParams.delete('show_edit'); + history.replaceState(history.state, '', url.href); } new ClipboardJS('#copyEventLink'); |