Update logout page

This commit is contained in:
Pierre HUBERT 2021-02-13 15:28:48 +01:00
parent 7c3946f376
commit 77b6c4d2f3
2 changed files with 14 additions and 33 deletions

View File

@ -13,12 +13,12 @@ ComunicWeb.pages.logout = {
* @param {element} targetElement Where the template will be applied * @param {element} targetElement Where the template will be applied
* @returns {Boolean} False if it fails * @returns {Boolean} False if it fails
*/ */
openLogoutPage: function(additionnalData, targetElement){ openLogoutPage: async function(additionnalData, targetElement){
//Enable screen overlay //Enable screen overlay
var screenOverlay = ComunicWeb.common.page.showTransparentWaitSplashScreen(); var screenOverlay = ComunicWeb.common.page.showTransparentWaitSplashScreen();
//Perform logout //Perform logout
ComunicWeb.user.userLogin.logoutUser(); await UserLogin.logoutUser();
//Reset notifications number //Reset notifications number
ComunicWeb.common.pageTitle.setNotificationsNumber(0); ComunicWeb.common.pageTitle.setNotificationsNumber(0);

View File

@ -145,42 +145,23 @@ const UserLogin = {
/** /**
* Logout user * Logout user
*
* @param {Function} afterLogout What to do once user is logged out
*/ */
logoutUser: async function(afterLogout){ logoutUser: async function(){
try {
await api("account/logout", {}, true);
await UserWebSocket.Disconnect();
await UserWebSocket.Disconnect();
//Prepare and make an API request //Destroy login tokens
var apiURI = "user/disconnectUSER"; ComunicWeb.user.loginTokens.deleteLoginTokens();
var params = {};
//What to do after the request is completed //Specify user is logged out
var afterAPIrequest = function(result){ this.__userID = 0;
this.__userLogin = false;
//Log } catch(e) {
ComunicWeb.debug.logMessage("Logout request on server terminated."); console.error(e);
}
//Perform next action (if specified)
if(afterLogout){
afterLogout();
}
};
//Perform request
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, afterAPIrequest);
//Destroy login tokens
ComunicWeb.user.loginTokens.deleteLoginTokens();
//Specify user is logged out
this.__userID = 0;
this.__userLogin = false;
//Done !
return 0;
}, },
/** /**