diff --git a/src/connectors/sso.ts b/src/connectors/sso.ts index b5a172a97e..fffb922f23 100644 --- a/src/connectors/sso.ts +++ b/src/connectors/sso.ts @@ -4,7 +4,12 @@ require('./sso.scss'); document.addEventListener('DOMContentLoaded', (event) => { const code = getQsParam('code'); const state = getQsParam('state'); - window.location.href = window.location.origin + '/#/sso?code=' + code + '&state=' + state; + + if (state != null && state.endsWith(':clientId=browser')) { + initiateBrowserSso(code, state); + } else { + window.location.href = window.location.origin + '/#/sso?code=' + code + '&state=' + state; + } }); function getQsParam(name: string) { @@ -22,3 +27,7 @@ function getQsParam(name: string) { return decodeURIComponent(results[2].replace(/\+/g, ' ')); } + +function initiateBrowserSso(code: string, state: string) { + window.postMessage({ command: 'authResult', code: code, state: state }, '*'); +}