From 5ec817e7f5aa21b7dd0e6aee2aaf92fa3a6cedeb Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 1 Feb 2022 10:43:23 +0100 Subject: [PATCH] MOBILE-3965 login: Always force logout when click 'Logout' button --- .../features/mainmenu/components/user-menu/user-menu.ts | 2 +- src/core/services/sites.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/features/mainmenu/components/user-menu/user-menu.ts b/src/core/features/mainmenu/components/user-menu/user-menu.ts index d250ae0e7..31e0c9137 100644 --- a/src/core/features/mainmenu/components/user-menu/user-menu.ts +++ b/src/core/features/mainmenu/components/user-menu/user-menu.ts @@ -169,7 +169,7 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy { async logout(event: Event): Promise { await this.close(event); - CoreSites.logout(); + CoreSites.logout(true); } /** diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index 6c5c5fca9..cd233fa27 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -1181,9 +1181,10 @@ export class CoreSitesProvider { /** * Logout the user. * + * @param forceLogout If true, site will be marked as logged out, no matter the value tool_mobile_forcelogout. * @return Promise resolved when the user is logged out. */ - async logout(): Promise { + async logout(forceLogout = false): Promise { if (!this.currentSite) { return; } @@ -1194,7 +1195,7 @@ export class CoreSitesProvider { this.currentSite = undefined; - if (siteConfig && siteConfig.tool_mobile_forcelogout == '1') { + if (forceLogout || (siteConfig && siteConfig.tool_mobile_forcelogout == '1')) { promises.push(this.setSiteLoggedOut(siteId)); } @@ -1222,7 +1223,7 @@ export class CoreSitesProvider { CoreApp.storeRedirect(siteId, redirectData); } - await CoreSites.logout(); + await this.logout(); return CoreSitePlugins.hasSitePluginsLoaded; }