mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-20 02:52:11 +00:00
Updated login, logout flow to update navbar
This commit is contained in:
parent
f81f8e76b0
commit
1daf695b45
@ -151,6 +151,23 @@ def me():
|
|||||||
# Return.
|
# Return.
|
||||||
return json_response(resp)
|
return json_response(resp)
|
||||||
|
|
||||||
|
@app.route('/logout')
|
||||||
|
def user_logout():
|
||||||
|
global is_logged_in
|
||||||
|
|
||||||
|
# Is the caller logged in?
|
||||||
|
if is_logged_in == True:
|
||||||
|
# User is now logged out
|
||||||
|
is_logged_in = False
|
||||||
|
return json_response({
|
||||||
|
"status": "ok"
|
||||||
|
})
|
||||||
|
|
||||||
|
# Return.
|
||||||
|
return json_response({
|
||||||
|
"status": "invalid"
|
||||||
|
})
|
||||||
|
|
||||||
# MAIL
|
# MAIL
|
||||||
|
|
||||||
@app.route('/mail/users')
|
@app.route('/mail/users')
|
||||||
|
@ -117,7 +117,10 @@ function do_login() {
|
|||||||
// Open the next panel the user wants to go to. Do this after the XHR response
|
// Open the next panel the user wants to go to. Do this after the XHR response
|
||||||
// is over so that we don't start a new XHR request while this one is finishing,
|
// is over so that we don't start a new XHR request while this one is finishing,
|
||||||
// which confuses the loading indicator.
|
// which confuses the loading indicator.
|
||||||
setTimeout(function() { show_panel(!switch_back_to_panel || switch_back_to_panel == "login" ? 'system_status' : switch_back_to_panel) }, 300);
|
setTimeout(function() {
|
||||||
|
window.location = "/admin";
|
||||||
|
show_panel(!switch_back_to_panel || switch_back_to_panel == "login" ? 'system_status' : switch_back_to_panel)
|
||||||
|
}, 300);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -128,7 +131,19 @@ function do_logout() {
|
|||||||
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");
|
||||||
|
|
||||||
|
api(
|
||||||
|
"/logout",
|
||||||
|
"GET",
|
||||||
|
{},
|
||||||
|
function (response) {
|
||||||
|
// This API call always succeeds. It returns a JSON object
|
||||||
|
// with a status based on whether or not the user was actually logged in.
|
||||||
|
if (response.status == "ok") {
|
||||||
|
window.location = "/admin";
|
||||||
show_panel('login');
|
show_panel('login');
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_login() {
|
function show_login() {
|
||||||
|
Loading…
Reference in New Issue
Block a user