From 9f578461e469175be8cf0d42fbd4bf621df9d8a8 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Thu, 23 Apr 2020 12:10:39 +0200 Subject: [PATCH] Automated cherry pick of #4203 (#4215) * Fix Crash on iOS with EMM enabled * Fix Android Passcode authentication * Fix Login screen header when EMM does not allow other servers Co-authored-by: Elias Nahum --- .../mattermost-managed.android.js | 5 ++-- app/screens/select_server/select_server.js | 17 +++++++++--- ios/Podfile.lock | 6 +++++ patches/react-native-local-auth+1.6.0.patch | 26 +++++++++++++++++++ 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/app/mattermost_managed/mattermost-managed.android.js b/app/mattermost_managed/mattermost-managed.android.js index 7b171ea52..acc5fcca2 100644 --- a/app/mattermost_managed/mattermost-managed.android.js +++ b/app/mattermost_managed/mattermost-managed.android.js @@ -36,11 +36,12 @@ export default { listeners.splice(index, 1); } }, - authenticate: () => { + authenticate: (opts) => { if (!LocalAuth) { LocalAuth = require('react-native-local-auth'); } - return LocalAuth.auth; + + return LocalAuth.auth(opts); }, blurAppScreen: emptyFunction, appGroupIdentifier: null, diff --git a/app/screens/select_server/select_server.js b/app/screens/select_server/select_server.js index 83932cb67..67e8590bc 100644 --- a/app/screens/select_server/select_server.js +++ b/app/screens/select_server/select_server.js @@ -67,6 +67,10 @@ export default class SelectServer extends PureComponent { serverUrl: PropTypes.string.isRequired, }; + static defaultProps = { + allowOtherServers: true, + }; + static contextTypes = { intl: intlShape.isRequired, }; @@ -159,11 +163,18 @@ export default class SelectServer extends PureComponent { }; goToNextScreen = (screen, title, passProps = {}, navOptions = {}) => { + const {allowOtherServers} = this.props; + let visible = !LocalConfig.AutoSelectServerUrl; + + if (!allowOtherServers) { + visible = false; + } + const defaultOptions = { - popGesture: !LocalConfig.AutoSelectServerUrl, + popGesture: visible, topBar: { - visible: !LocalConfig.AutoSelectServerUrl, - height: LocalConfig.AutoSelectServerUrl ? 0 : null, + visible, + height: visible ? null : 0, }, }; const options = merge(defaultOptions, navOptions); diff --git a/ios/Podfile.lock b/ios/Podfile.lock index e1fc468d6..a9a3ce290 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -215,6 +215,8 @@ PODS: - React - react-native-image-picker (2.3.1): - React + - react-native-local-auth (1.6.0): + - React - react-native-mmkv-storage (0.3.1): - MMKV (= 1.1.0) - React @@ -344,6 +346,7 @@ DEPENDENCIES: - react-native-document-picker (from `../node_modules/react-native-document-picker`) - react-native-hw-keyboard-event (from `../node_modules/react-native-hw-keyboard-event`) - react-native-image-picker (from `../node_modules/react-native-image-picker`) + - react-native-local-auth (from `../node_modules/react-native-local-auth`) - react-native-mmkv-storage (from `../node_modules/react-native-mmkv-storage`) - "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)" - react-native-notifications (from `../node_modules/react-native-notifications`) @@ -443,6 +446,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-hw-keyboard-event" react-native-image-picker: :path: "../node_modules/react-native-image-picker" + react-native-local-auth: + :path: "../node_modules/react-native-local-auth" react-native-mmkv-storage: :path: "../node_modules/react-native-mmkv-storage" react-native-netinfo: @@ -539,6 +544,7 @@ SPEC CHECKSUMS: react-native-document-picker: 0573c02d742d4bef38a5d16b5f039754cfa69888 react-native-hw-keyboard-event: b517cefb8d5c659a38049c582de85ff43337dc53 react-native-image-picker: 668e72d0277dc8c12ae90e835507c1eddd2e4f85 + react-native-local-auth: 359af242caa1e5c501ac9dfe33b1e238ad8f08c6 react-native-mmkv-storage: d413e1e00b1f410a744e1d547a912a1f87e67260 react-native-netinfo: 892a5130be97ff8bb69c523739c424a2ffc296d1 react-native-notifications: d5cb54ef8bf3004dcb56c887650dea08ecbddee7 diff --git a/patches/react-native-local-auth+1.6.0.patch b/patches/react-native-local-auth+1.6.0.patch index 36847dc88..638ffc854 100644 --- a/patches/react-native-local-auth+1.6.0.patch +++ b/patches/react-native-local-auth+1.6.0.patch @@ -170,3 +170,29 @@ index 38b78f1..a47afea 100644 } catch (Exception e) { authPromise.reject(E_FAILED_TO_SHOW_AUTH, e); authPromise = null; +diff --git a/node_modules/react-native-local-auth/react-native-local-auth.podspec b/node_modules/react-native-local-auth/react-native-local-auth.podspec +new file mode 100644 +index 0000000..5f9a6b4 +--- /dev/null ++++ b/node_modules/react-native-local-auth/react-native-local-auth.podspec +@@ -0,0 +1,20 @@ ++require "json" ++package = JSON.parse(File.read(File.join(__dir__, '/package.json'))) ++ ++Pod::Spec.new do |s| ++ s.name = package['name'] ++ s.version = package['version'] ++ s.summary = package['description'] ++ s.description = package['description'] ++ s.homepage = package['homepage'] ++ s.license = package['license'] ++ s.author = package['author'] ++ s.source = { :git => 'https://github.com/tradle/react-native-local-auth.git' } ++ ++ s.platform = :ios, '9.0' ++ s.ios.deployment_target = '9.0' ++ ++ s.source_files = "*.{h,m}" ++ ++ s.dependency 'React' ++end