FIX: Now able to use biometrics with encrypted storage (not for unlocking)

This commit is contained in:
Marcos Rodriguez 2019-10-16 21:33:00 -04:00 committed by Overtorment
parent 15488b668f
commit b9cf5c6172
3 changed files with 16 additions and 18 deletions

View File

@ -18,9 +18,8 @@ export default class UnlockWith extends Component {
}
const isStorageEncrypted = await BlueApp.storageIsEncrypted();
this.setState({ biometricType, isStorageEncrypted }, async () => {
if (!biometricType) {
await BlueApp.startAndDecrypt();
this.props.onSuccessfullyAuthenticated();
if (!biometricType || isStorageEncrypted) {
this.unlockWithKey();
} else if (typeof biometricType === 'string') this.unlockWithBiometrics();
});
}
@ -29,7 +28,10 @@ export default class UnlockWith extends Component {
this.props.onSuccessfullyAuthenticated();
};
unlockWithBiometrics = () => {
unlockWithBiometrics = async () => {
if (await BlueApp.storageIsEncrypted()) {
this.unlockWithKey();
}
this.setState({ isAuthenticating: true }, async () => {
if (await Biometric.unlockWithBiometrics()) {
await BlueApp.startAndDecrypt();
@ -58,14 +60,14 @@ export default class UnlockWith extends Component {
</View>
<View style={{ flex: 0.2, justifyContent: 'flex-end', marginBottom: 58 }}>
<View style={{ justifyContent: 'center', flexDirection: 'row' }}>
{this.state.biometricType === Biometric.TouchID && (
{this.state.biometricType === Biometric.TouchID && !this.state.isStorageEncrypted && (
<>
<TouchableOpacity disabled={this.state.isAuthenticating} onPress={this.unlockWithBiometrics}>
<Image source={require('./img/fingerprint.png')} style={{ width: 64, height: 64 }} />
</TouchableOpacity>
</>
)}
{this.state.biometricType === Biometric.FaceID && (
{this.state.biometricType === Biometric.FaceID && !this.state.isStorageEncrypted && (
<>
<TouchableOpacity disabled={this.state.isAuthenticating} onPress={this.unlockWithBiometrics}>
<Image source={require('./img/faceid.png')} style={{ width: 64, height: 64 }} />

View File

@ -16,9 +16,6 @@ export default class Biometric {
}
static async biometricType() {
if (await BlueApp.storageIsEncrypted()) {
return null;
}
return Biometrics.isSensorAvailable();
}

View File

@ -33,7 +33,7 @@ export default class WalletDetails extends Component {
headerRight: (
<TouchableOpacity
disabled={navigation.getParam('isLoading') === true}
style={{ marginHorizontal: 16, height: 40, width: 120, justifyContent: 'center', alignItems: 'center' }}
style={{ marginHorizontal: 16, justifyContent: 'center', alignItems: 'center' }}
onPress={() => {
if (navigation.state.params.saveAction) {
navigation.getParam('saveAction')();
@ -86,14 +86,6 @@ export default class WalletDetails extends Component {
'plain-text',
);
if (Number(walletBalanceConfirmation) === this.state.wallet.getBalance()) {
const isBiometricsEnabled = await Biometric.isBiometricUseCapableAndEnabled();
if (isBiometricsEnabled) {
if (!(await Biometric.unlockWithBiometrics())) {
return;
}
}
this.props.navigation.setParams({ isLoading: true });
this.setState({ isLoading: true }, async () => {
BlueApp.deleteWallet(this.state.wallet);
@ -255,6 +247,13 @@ export default class WalletDetails extends Component {
{
text: loc.wallets.details.yes_delete,
onPress: async () => {
const isBiometricsEnabled = await Biometric.isBiometricUseCapableAndEnabled();
if (isBiometricsEnabled) {
if (!(await Biometric.unlockWithBiometrics())) {
return;
}
}
if (this.state.wallet.getBalance() > 0) {
this.presentWalletHasBalanceAlert();
} else {