From a1e8a52e3f2a8fd2b0d0aa2afa953220a8a81e64 Mon Sep 17 00:00:00 2001 From: Ayman Habeb Date: Thu, 28 Jul 2022 08:19:25 -0700 Subject: [PATCH] hotfixes hotfix to handle oauth2 users --- src/widget/formatSSO.js | 10 +++++++++- src/widget/widget.js | 13 +++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/widget/formatSSO.js b/src/widget/formatSSO.js index 9bd534a..8c005fc 100644 --- a/src/widget/formatSSO.js +++ b/src/widget/formatSSO.js @@ -8,4 +8,12 @@ export const formatSSO = (url, ssoUserString) => { } return url.replace('{{SSO}}', ''); -}; \ No newline at end of file +}; + +export const formatOAuth = (url, accessToken) => { + if (accessToken) { + return url.replace('{{SSO}}', encodeURIComponent(accessToken)); + } + + return url.replace('{{SSO}}', ''); +}; diff --git a/src/widget/widget.js b/src/widget/widget.js index ceee849..43788d3 100644 --- a/src/widget/widget.js +++ b/src/widget/widget.js @@ -1,5 +1,5 @@ const buildfire = require('buildfire'); -const { formatSSO } = require('./formatSSO'); +const { formatSSO, formatOAuth } = require('./formatSSO'); const viewOptions = { POPUP: 'In app popup', @@ -55,6 +55,15 @@ const render = (content) => { content.url = formatSSO(content.url, JSON.stringify(result.SSO)); handleWindow(openWindow, displayIniFrame, displaySuccessMessage); } + else{ + if (result && result.oauthProfile && result.oauthProfile.accessToken) { + content.url = formatOAuth(content.url, result.oauthProfile.accessToken); + handleWindow(openWindow, displayIniFrame, displaySuccessMessage); + } + else{ + handleWindow(openWindow, displayIniFrame, displaySuccessMessage); + } + } }); } else { //this is all other URLs, i.e. no SSO. handleWindow(openWindow, displayIniFrame, displaySuccessMessage); @@ -101,7 +110,7 @@ const renderiFrame = (props) =>{ let container = props.isIOS ? scrollable : window.document.body; container.appendChild((() => { - + if (flags.isWeb) { let modal = (document.querySelectorAll('div[id^="confirm"]') || [])[0]; if (modal) {