From faec272c5053587151e1dc094b339c1287949d7b Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 23 Jan 2025 11:53:41 +0100 Subject: [PATCH] Clear credentials and reset menu after receiving 403 --- management/templates/index.html | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/management/templates/index.html b/management/templates/index.html index a468ffb9..42e7d636 100644 --- a/management/templates/index.html +++ b/management/templates/index.html @@ -392,7 +392,9 @@ function api(url, method, data, callback, callback_error, headers) { 403: function(xhr) { // Credentials are no longer valid. Try to login again. var p = current_panel; + clear_credentials(); show_panel('login'); + show_hide_menus(); switch_back_to_panel = p; } } @@ -402,16 +404,21 @@ function api(url, method, data, callback, callback_error, headers) { var current_panel = null; var switch_back_to_panel = null; -function do_logout() { - // Clear the session from the backend. - api("/logout", "POST"); - +function clear_credentials() { // Forget the token. api_credentials = null; if (typeof localStorage != 'undefined') localStorage.removeItem("miab-cp-credentials"); if (typeof sessionStorage != 'undefined') sessionStorage.removeItem("miab-cp-credentials"); +} + +function do_logout() { + // Clear the session from the backend. + api("/logout", "POST"); + + // Remove locally stored credentials + clear_credentials(); // Return to the start. show_panel('login');