Skip to content

Commit

Permalink
Merge pull request #154 from BeInLife/patch-1
Browse files Browse the repository at this point in the history
Changes to avoid Keychain Prompt on Login screen (Android)
  • Loading branch information
jeremy-farnault authored Sep 11, 2020
2 parents 1373a1c + 0668681 commit 99299f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/PinCodeChoose.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PinCode, { PinStatus } from './PinCode'
import { noBiometricsConfig } from './utils'

import * as React from 'react'
import { StyleProp, StyleSheet, TextStyle, View, ViewStyle } from 'react-native'
Expand Down Expand Up @@ -101,7 +102,8 @@ class PinCodeChoose extends React.PureComponent<IProps, IState> {
await Keychain.setInternetCredentials(
this.props.pinCodeKeychainName,
this.props.pinCodeKeychainName,
pinCode
pinCode,
noBiometricsConfig
)
}
if (!!this.props.finishProcess) this.props.finishProcess(pinCode)
Expand Down
5 changes: 3 additions & 2 deletions src/PinCodeEnter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import delay from './delay'
import PinCode, { PinStatus } from './PinCode'
import { PinResultStatus } from './utils'
import { PinResultStatus, noBiometricsConfig } from './utils'

import AsyncStorage from '@react-native-community/async-storage'
import * as React from 'react'
Expand Down Expand Up @@ -112,7 +112,8 @@ class PinCodeEnter extends React.PureComponent<IProps, IState> {
this.launchTouchID = this.launchTouchID.bind(this)
if (!this.props.storedPin) {
Keychain.getInternetCredentials(
this.props.pinCodeKeychainName
this.props.pinCodeKeychainName,
noBiometricsConfig
).then(result => {
this.keyChainResult = result && result.password || undefined
}).catch(error => {
Expand Down
8 changes: 8 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Platform } from 'react-native'
import AsyncStorage from '@react-native-community/async-storage'
import * as Keychain from 'react-native-keychain'

Expand All @@ -21,3 +22,10 @@ export const deletePinCode = async (serviceName: string) => {
export const resetInternalStates = async (asyncStorageKeys: string[]) => {
return await AsyncStorage.multiRemove(asyncStorageKeys)
}

export const noBiometricsConfig = Platform.select({
android: {
accessControl: Keychain.ACCESS_CONTROL.APPLICATION_PASSWORD,
},
ios: {}
})

0 comments on commit 99299f0

Please sign in to comment.