From 0f968c6986e1101816db33a6f9d4c45ddb6e3464 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 15 Oct 2020 09:02:09 +0200 Subject: [PATCH] MOBILE-3523 login: Fix consecutive logins if logout+SSO --- src/core/mainmenu/pages/menu/menu.ts | 6 ++++-- src/providers/sites.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/mainmenu/pages/menu/menu.ts b/src/core/mainmenu/pages/menu/menu.ts index bdf1cdbd4..bc2d6e39d 100644 --- a/src/core/mainmenu/pages/menu/menu.ts +++ b/src/core/mainmenu/pages/menu/menu.ts @@ -46,6 +46,7 @@ export class CoreMainMenuPage implements OnDestroy { protected urlToOpen: string; protected mainMenuId: number; protected keyboardObserver: any; + protected resizeFunction; @ViewChild('mainTabs') mainTabs: CoreIonTabsComponent; @@ -115,7 +116,8 @@ export class CoreMainMenuPage implements OnDestroy { } }); - window.addEventListener('resize', this.initHandlers.bind(this)); + this.resizeFunction = this.initHandlers.bind(this); + window.addEventListener('resize', this.resizeFunction); if (CoreApp.instance.isIOS()) { // In iOS, the resize event is triggered before the keyboard is opened/closed and not triggered again once done. @@ -241,7 +243,7 @@ export class CoreMainMenuPage implements OnDestroy { ngOnDestroy(): void { this.subscription && this.subscription.unsubscribe(); this.redirectObs && this.redirectObs.off(); - window.removeEventListener('resize', this.initHandlers.bind(this)); + window.removeEventListener('resize', this.resizeFunction); CoreApp.instance.setMainMenuOpen(this.mainMenuId, false); this.keyboardObserver && this.keyboardObserver.off(); } diff --git a/src/providers/sites.ts b/src/providers/sites.ts index 99e60cb42..124b68e71 100644 --- a/src/providers/sites.ts +++ b/src/providers/sites.ts @@ -1549,11 +1549,16 @@ export class CoreSitesProvider { await this.dbReady; const site = await this.getSite(siteId); - const newValues = { - token: '', // Erase the token for security. + const newValues: any = { loggedOut: loggedOut ? 1 : 0 }; + if (loggedOut) { + // Erase the token for security. + newValues.token = ''; + site.token = ''; + } + site.setLoggedOut(loggedOut); return this.appDB.updateRecords(CoreSitesProvider.SITES_TABLE, newValues, { id: siteId });