Do not use WebKit for CookieManager operations in SSO (#2515)

* Do not use WebKit for CookieManager operations in SSO

This allows the SSO login to function again with devices that are not running IOS-11.

* Use WebKit for CookieManager operations only with iOS 11 or later

Detect OS version and use WebKit only when iOS 11 or later is detected.
This allows the SSO login to function again with older devices.
This commit is contained in:
Antti Seppälä 2019-03-22 18:41:06 +02:00 committed by Elias Nahum
parent b5effd3ea3
commit a52bc4ca2e

View file

@ -8,6 +8,7 @@ import {
InteractionManager,
Text,
View,
Platform,
} from 'react-native';
import {WebView} from 'react-native-webview';
import CookieManager from 'react-native-cookies';
@ -71,6 +72,8 @@ class SSO extends PureComponent {
}).isRequired,
};
useWebkit = true;
constructor(props) {
super(props);
@ -95,6 +98,10 @@ class SSO extends PureComponent {
this.completedUrl = '/signup/office365/complete';
break;
}
if (Platform.OS === 'ios') {
this.useWebkit = parseInt(Platform.Version, 10) >= 11;
}
}
componentDidMount() {
@ -102,7 +109,7 @@ class SSO extends PureComponent {
}
clearPreviousCookies = () => {
CookieManager.clearAll(true).then(() => {
CookieManager.clearAll(this.useWebkit).then(() => {
this.setState({renderWebView: true});
});
};
@ -168,7 +175,7 @@ class SSO extends PureComponent {
onLoadEnd = (event) => {
const url = event.nativeEvent.url;
if (url.includes(this.completedUrl)) {
CookieManager.get(urlParse(url).origin, true).then((res) => {
CookieManager.get(urlParse(url).origin, this.useWebkit).then((res) => {
const token = res.MMAUTHTOKEN;
if (token) {
@ -237,7 +244,7 @@ class SSO extends PureComponent {
injectedJavaScript={jsCode}
onLoadEnd={this.onLoadEnd}
onMessage={messagingEnabled ? this.onMessage : null}
useWebKit={true}
useWebKit={this.useWebkit}
useSharedProcessPool={true}
cacheEnabled={true}
/>