From f7c7e70a37806bbce5cc02b7f79e68119590a0d0 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Wed, 26 Sep 2018 11:40:28 -0300 Subject: [PATCH] Fix SSO error display (#2158) --- app/screens/sso/sso.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/screens/sso/sso.js b/app/screens/sso/sso.js index f9265c059..ff01538e7 100644 --- a/app/screens/sso/sso.js +++ b/app/screens/sso/sso.js @@ -26,7 +26,7 @@ const HEADERS = { 'X-Mobile-App': 'mattermost', }; -const postMessageJS = "setTimeout(function() { postMessage(document.body.innerText, '*')}, 0);"; +const postMessageJS = "postMessage(document.body.innerText, '*');"; // Used to make sure that OneLogin forms scale appropriately on both platforms. const oneLoginFormScalingJS = ` @@ -158,14 +158,9 @@ class SSO extends PureComponent { const {url} = navState; const nextState = {}; const parsed = urlParse(url); - const serverUrl = urlParse(this.props.serverUrl); if (parsed.host.includes('.onelogin.com')) { nextState.jsCode = oneLoginFormScalingJS; - } else if (serverUrl.host === parsed.host) { - nextState.jsCode = postMessageJS; - } else { - nextState.jsCode = ''; } if (Object.keys(nextState).length) { @@ -193,6 +188,8 @@ class SSO extends PureComponent { then(getSession). then(this.goToLoadTeam). catch(this.onLoadEndError); + } else if (this.webView && !this.state.error) { + this.webView.injectJavaScript(postMessageJS); } }); } @@ -207,6 +204,10 @@ class SSO extends PureComponent { return ; }; + webViewRef = (ref) => { + this.webView = ref; + }; + render() { const {theme} = this.props; const {error, renderWebView, jsCode} = this.state; @@ -224,6 +225,7 @@ class SSO extends PureComponent { } else { content = (