Save biometry column

This commit is contained in:
Diego Mello 2020-04-24 15:43:31 -03:00
parent 9f3b932189
commit bb09aa09c7
2 changed files with 21 additions and 11 deletions

View File

@ -57,16 +57,26 @@ export const localAuthenticate = async(server) => {
// Make sure splash screen has been hidden // Make sure splash screen has been hidden
RNBootSplash.hide(); RNBootSplash.hide();
const isEnrolled = await LocalAuthentication.isEnrolledAsync(); // if biometry is enabled on the app
const isSupported = await LocalAuthentication.supportedAuthenticationTypesAsync(); if (serverRecord?.biometry) {
const isEnrolled = await LocalAuthentication.isEnrolledAsync();
const isSupported = await LocalAuthentication.supportedAuthenticationTypesAsync();
// if biometry is enabled and enrolled on OS // if biometry is enabled and enrolled on OS
if (isEnrolled && isSupported) { if (isEnrolled && isSupported?.length) {
// opens biometry prompt // opens biometry prompt
const authResult = await LocalAuthentication.authenticateAsync({ disableDeviceFallback: true }); let authResult;
if (authResult?.success) { try {
await resetAttempts(); authResult = await LocalAuthentication.authenticateAsync({ disableDeviceFallback: true });
await saveLastLocalAuthenticationSession(server, serverRecord); } catch (e) {
// Do nothing
}
if (authResult?.success) {
await resetAttempts();
await saveLastLocalAuthenticationSession(server, serverRecord);
} else {
await localPasscode();
}
} else { } else {
await localPasscode(); await localPasscode();
} }

View File

@ -83,7 +83,7 @@ class ScreenLockConfigView extends React.Component {
this.setState({ this.setState({
autoLock: this.serverRecord?.autoLock, autoLock: this.serverRecord?.autoLock,
autoLockTime: this.serverRecord?.autoLockTime || 1800, autoLockTime: this.serverRecord?.autoLockTime || 1800,
biometry: this.serverRecord?.biometry || true biometry: this.serverRecord.biometry === null ? true : this.serverRecord.biometry
}); });
} catch (error) { } catch (error) {
// Do nothing // Do nothing
@ -100,7 +100,7 @@ class ScreenLockConfigView extends React.Component {
await this.serverRecord?.update((record) => { await this.serverRecord?.update((record) => {
record.autoLock = autoLock; record.autoLock = autoLock;
record.autoLockTime = autoLockTime; record.autoLockTime = autoLockTime;
record.biometry = biometry; record.biometry = biometry === null ? true : biometry;
}); });
}); });
} }