A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
add basic fingerprint auth on app launch
ammarahm-eddf65a504ae8b
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex d77335863..c40b06f14 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -1,4 +1,5 @@import React, {useEffect} from 'react';+import {BackHandler} from 'react-native';import Orientation from 'react-native-orientation';import {SafeAreaProvider} from 'react-native-safe-area-context';import SplashScreen from 'react-native-splash-screen';@@ -7,7 +8,9 @@ import {RootView} from './initializer.root';import AppLoader from './src/components/AppLoader';import {useTracked} from './src/provider';import {Actions} from './src/provider/Actions';+import BiometricService from './src/services/BiometricService';import {DDS} from './src/services/DeviceDetection';+import RNExitApp from 'react-native-exit-app';import {eSendEvent,eSubscribeEvent,@@ -36,10 +39,28 @@ const App = () => {: 'mobile',});});++ let func = async () => {+ eSendEvent(eOpenSideMenu);+ SplashScreen.hide();+ await db.init();+ };+await SettingsService.init();- eSendEvent(eOpenSideMenu);- SplashScreen.hide();- await db.init();+ if (SettingsService.get().appLockMode !== 'none') {+ let result = await BiometricService.validateUser(+ 'Unlock to access your notes',+ '',+ );+ if (result) {+ await func();+ } else {+ RNExitApp.exitApp();+ return;+ }+ } else {+ await func();+ }} catch (e) {} finally {initStatus = true;diff --git a/apps/mobile/src/provider/DefaultState.js b/apps/mobile/src/provider/DefaultState.jsindex 3624e2f99..2aba5b86a 100644--- a/apps/mobile/src/provider/DefaultState.js+++ b/apps/mobile/src/provider/DefaultState.js@@ -31,6 +31,7 @@ export const defaultState = {sortOrder: 'desc',screenshotMode: true,privacyScreen: false,+ appLockMode:'launch'},currentScreen: 'Notes',deviceMode:null,diff --git a/apps/mobile/src/services/BiometricService.js b/apps/mobile/src/services/BiometricService.jsindex 997bd537c..1281454fe 100644--- a/apps/mobile/src/services/BiometricService.js+++ b/apps/mobile/src/services/BiometricService.js@@ -87,6 +87,44 @@ async function getCredentials(title, description) {}}+async function validateUser(title, description) {+ try {+ await FingerprintScanner.authenticate(+ Platform.select({+ ios: {+ fallbackEnabled: true,+ description: description,+ },+ android: {+ title: title,+ description: description,+ deviceCredentialAllowed: true,+ },+ }),+ );+ FingerprintScanner.release();+ return true;+ } catch (e) {+ FingerprintScanner.release();+ if (e.name === 'DeviceLocked') {+ ToastEvent.show({+ heading: 'Biometrics authentication failed.',+ message: 'Wait 30 seconds to try again.',+ type: 'error',+ context: 'local',+ });+ } else {+ ToastEvent.show({+ heading: 'Authentication failed.',+ message: 'Tap to try again.',+ type: 'error',+ context: 'local',+ });+ }+ return false;+ }+}+export default {isBiometryAvailable,enableFingerprintAuth,@@ -95,4 +133,5 @@ export default {getCredentials,storeCredentials,hasInternetCredentials,+ validateUser};