mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-01-23 12:37:05 +00:00
Clear credentials and reset menu after receiving 403
This commit is contained in:
parent
e6c354c312
commit
faec272c50
@ -392,7 +392,9 @@ function api(url, method, data, callback, callback_error, headers) {
|
|||||||
403: function(xhr) {
|
403: function(xhr) {
|
||||||
// Credentials are no longer valid. Try to login again.
|
// Credentials are no longer valid. Try to login again.
|
||||||
var p = current_panel;
|
var p = current_panel;
|
||||||
|
clear_credentials();
|
||||||
show_panel('login');
|
show_panel('login');
|
||||||
|
show_hide_menus();
|
||||||
switch_back_to_panel = p;
|
switch_back_to_panel = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,16 +404,21 @@ function api(url, method, data, callback, callback_error, headers) {
|
|||||||
var current_panel = null;
|
var current_panel = null;
|
||||||
var switch_back_to_panel = null;
|
var switch_back_to_panel = null;
|
||||||
|
|
||||||
function do_logout() {
|
function clear_credentials() {
|
||||||
// Clear the session from the backend.
|
|
||||||
api("/logout", "POST");
|
|
||||||
|
|
||||||
// Forget the token.
|
// Forget the token.
|
||||||
api_credentials = null;
|
api_credentials = null;
|
||||||
if (typeof localStorage != 'undefined')
|
if (typeof localStorage != 'undefined')
|
||||||
localStorage.removeItem("miab-cp-credentials");
|
localStorage.removeItem("miab-cp-credentials");
|
||||||
if (typeof sessionStorage != 'undefined')
|
if (typeof sessionStorage != 'undefined')
|
||||||
sessionStorage.removeItem("miab-cp-credentials");
|
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.
|
// Return to the start.
|
||||||
show_panel('login');
|
show_panel('login');
|
||||||
|
Loading…
Reference in New Issue
Block a user