From ac6e3a68f031738f7075db7ed2efd0cc0e24cf4d Mon Sep 17 00:00:00 2001 From: Isuru Gajanayake Date: Thu, 10 Dec 2020 08:49:54 -0600 Subject: [PATCH] social auth without popup or tab --- src/oauth/oauth1.js | 2 +- src/oauth/oauth2.js | 2 +- src/oauth/popup.js | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/oauth/oauth1.js b/src/oauth/oauth1.js index 661bb58..c1bc039 100644 --- a/src/oauth/oauth1.js +++ b/src/oauth/oauth1.js @@ -31,7 +31,7 @@ export default class OAuth { * @return {Promise} */ init(userData) { - this.oauthPopup = new OAuthPopup('about:blank', this.providerConfig.name, this.providerConfig.popupOptions) + this.oauthPopup = new OAuthPopup('about:blank', this.providerConfig.name, this.providerConfig.display, this.providerConfig.popupOptions) if (!$window['cordova']) { this.oauthPopup.open(this.providerConfig.redirectUri, true) diff --git a/src/oauth/oauth2.js b/src/oauth/oauth2.js index 3b9fe06..2d811cb 100644 --- a/src/oauth/oauth2.js +++ b/src/oauth/oauth2.js @@ -46,7 +46,7 @@ export default class OAuth2 { let url = [this.providerConfig.authorizationEndpoint, this._stringifyRequestParams()].join('?') - this.oauthPopup = new OAuthPopup(url, this.providerConfig.name, this.providerConfig.popupOptions) + this.oauthPopup = new OAuthPopup(url, this.providerConfig.name, this.providerConfig.display, this.providerConfig.popupOptions) return new Promise((resolve, reject) => { this.oauthPopup.open(this.providerConfig.redirectUri).then((response) => { diff --git a/src/oauth/popup.js b/src/oauth/popup.js index 9d5e509..04a638a 100644 --- a/src/oauth/popup.js +++ b/src/oauth/popup.js @@ -10,18 +10,23 @@ import { objectExtend, parseQueryString, getFullUrlPath, isUndefined } from '../ * and adjusted to fit vue-authenticate library */ export default class OAuthPopup { - constructor(url, name, popupOptions) { + constructor(url, name, display, popupOptions) { this.popup = null this.url = url this.name = name this.popupOptions = popupOptions + this.display = display } open(redirectUri, skipPooling) { try { - this.popup = $window.open(this.url, this.name, this._stringifyOptions()) - if (this.popup && this.popup.focus) { - this.popup.focus() + if (this.display == 'page') { + this.popup = $window.open(this.url, '_self', this._stringifyOptions()) + } else { + this.popup = $window.open(this.url, this.name, this._stringifyOptions()) + if (this.popup && this.popup.focus) { + this.popup.focus() + } } if (skipPooling) {