Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

do not lock app if requesting fingerprint unlock for vault

ammarahm-ed1941a49cee45
diff --git a/apps/mobile/src/services/BiometricService.js b/apps/mobile/src/services/BiometricService.js
index 5d865606f..e0bd22451 100644
--- a/apps/mobile/src/services/BiometricService.js
+++ b/apps/mobile/src/services/BiometricService.js
@@ -4,6 +4,7 @@ import { ToastEvent } from './EventManager';
import * as Keychain from 'react-native-keychain';
import { Platform } from 'react-native';
import { MMKV } from '../utils/mmkv';
+import { useSettingStore } from '../provider/stores';
const CRYPT_CONFIG = Platform.select({
ios: {
@@ -45,6 +46,7 @@ async function hasInternetCredentials() {
async function getCredentials(title, description) {
try {
+ useSettingStore.getState().setRequestBiometrics(true);
await FingerprintScanner.authenticate(
Platform.select({
ios: {
@@ -61,6 +63,7 @@ async function getCredentials(title, description) {
FingerprintScanner.release();
return await Keychain.getInternetCredentials('nn_vault', CRYPT_CONFIG);
} catch (e) {
+ useSettingStore.getState().setRequestBiometrics(false);
FingerprintScanner.release();
let message = {
heading: 'Authentication with biometrics failed.',
diff --git a/apps/mobile/src/utils/useAppEvents.js b/apps/mobile/src/utils/useAppEvents.js
index 1ea9a2659..c0a37610d 100644
--- a/apps/mobile/src/utils/useAppEvents.js
+++ b/apps/mobile/src/utils/useAppEvents.js
@@ -21,6 +21,7 @@ import {
initialize,
useAttachmentStore,
useNoteStore,
+ useSettingStore,
useUserStore
} from '../provider/stores';
import Backup from '../services/Backup';
@@ -399,6 +400,11 @@ export const useAppEvents = () => {
}
if (SettingsService.get().appLockMode === 'background') {
+ if (useSettingStore.getState().requestBiometrics) {
+ console.log('requesting biometrics');
+ useSettingStore.getState().setRequestBiometrics(false);
+ return;
+ }
if (refValues.current?.prevState === 'background' && !refValues.current?.showingDialog) {
refValues.current.showingDialog = true;
refValues.current.prevState = 'active';