Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear credentials and reset menu after receiving 403 #2477

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions management/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,9 @@ <h4 class="modal-title" id="errorModalTitle"> </h4>
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;
}
}
Expand All @@ -402,16 +404,21 @@ <h4 class="modal-title" id="errorModalTitle"> </h4>
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');
Expand Down