From c15f0cfd7e17d74703465e33fb4064d4b4d39645 Mon Sep 17 00:00:00 2001 From: Anil Gupta Date: Thu, 27 Dec 2018 14:27:23 +0530 Subject: [PATCH] Issue #SB-8909 feat: Fixed logout issue. --- src/services/auth/oauth.service.ts | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/services/auth/oauth.service.ts b/src/services/auth/oauth.service.ts index 7089260..421d343 100644 --- a/src/services/auth/oauth.service.ts +++ b/src/services/auth/oauth.service.ts @@ -72,7 +72,6 @@ export class OAuthService { } doOAuthStepOne(isRTL = false): Promise { - return new Promise((resolve, reject) => { customtabs.isAvailable(() => { //customtabs available @@ -112,8 +111,7 @@ export class OAuthService { return new Promise(function (resolve, reject) { if (that.isGoogleSignup(token)) { that.createInAppSession(that.getQueryParam(token, 'refresh_token'), that.getQueryParam(token, 'access_token'), resolve, reject); - } - else { + } else { that.authService.createSession(token, (response) => { try { let dataJson = JSON.parse(response); @@ -127,7 +125,6 @@ export class OAuthService { reject(error); }); } - }); } @@ -198,26 +195,23 @@ export class OAuthService { } doLogOut(): Promise { - return new Promise((resolve, reject) => { customtabs.isAvailable(() => { customtabs.launch(this.logout_url!!, success => { + this.authService.endSession(); resolve(); }, error => { - reject(); + reject(error); }); }, error => { - let browserRef = (window).cordova.InAppBrowser.open(this.logout_url); - browserRef.addEventListener("loadstart", (event) => { - if ((event.url).indexOf(this.redirect_url) === 0) { - browserRef.removeEventListener("exit", (event) => { }); - browserRef.close(); - this.authService.endSession(); - resolve(); - } + customtabs.launchInBrowser(this.logout_url!!, callbackUrl => { + this.authService.endSession(); + resolve(); + }, error => { + reject(error); }); }); }); } -} \ No newline at end of file +}