From 77b6c4d2f31782a20893704c9fa6630a94c3ff2c Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 13 Feb 2021 15:28:48 +0100 Subject: [PATCH] Update logout page --- assets/js/pages/logout.js | 4 ++-- assets/js/user/userLogin.js | 43 +++++++++++-------------------------- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/assets/js/pages/logout.js b/assets/js/pages/logout.js index 9d1cec30..3f043232 100644 --- a/assets/js/pages/logout.js +++ b/assets/js/pages/logout.js @@ -13,12 +13,12 @@ ComunicWeb.pages.logout = { * @param {element} targetElement Where the template will be applied * @returns {Boolean} False if it fails */ - openLogoutPage: function(additionnalData, targetElement){ + openLogoutPage: async function(additionnalData, targetElement){ //Enable screen overlay var screenOverlay = ComunicWeb.common.page.showTransparentWaitSplashScreen(); //Perform logout - ComunicWeb.user.userLogin.logoutUser(); + await UserLogin.logoutUser(); //Reset notifications number ComunicWeb.common.pageTitle.setNotificationsNumber(0); diff --git a/assets/js/user/userLogin.js b/assets/js/user/userLogin.js index 3ffd33d1..e2a8499f 100644 --- a/assets/js/user/userLogin.js +++ b/assets/js/user/userLogin.js @@ -145,42 +145,23 @@ const UserLogin = { /** * 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 - var apiURI = "user/disconnectUSER"; - var params = {}; + //Destroy login tokens + ComunicWeb.user.loginTokens.deleteLoginTokens(); - //What to do after the request is completed - var afterAPIrequest = function(result){ + //Specify user is logged out + this.__userID = 0; + this.__userLogin = false; - //Log - ComunicWeb.debug.logMessage("Logout request on server terminated."); - - //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; + } catch(e) { + console.error(e); + } }, /**