Skip to content

Commit

Permalink
fix: login bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
manu0466 committed Mar 8, 2024
1 parent dbe8e67 commit dc143b5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line import/no-unresolved
import React from 'react';
import React, { useCallback } from 'react';
import { RecoilRoot } from 'recoil';
import { NavigationContainer } from '@react-navigation/native';
import RootNavigator from 'navigation/RootNavigator';
Expand All @@ -14,6 +14,8 @@ import useCheckKeyChainIntegrity from 'hooks/dataintegrity/useCheckKeyChainInteg
import useInitNotifications from 'hooks/notifications/useInitNotifications';
import { getCachedUriAction, isUriActionPending, onCachedUriActionChange } from 'lib/UriActions';
import { useSetUriAction } from '@recoil/uriaction';
import { useAppState, useSetAppState } from '@recoil/appState';
import { useSetting } from '@recoil/settings';

const AppLockLogic = () => {
useLockApplicationOnBlur();
Expand All @@ -24,19 +26,27 @@ const AppLockLogic = () => {

const Navigation = () => {
const setUriAction = useSetUriAction();
const { ready } = useAppState();
const setAppState = useSetAppState();
const showUnlockApplicationScreen = useSetting('autoAppLock');

React.useEffect(() => {
if (isUriActionPending()) {
if (ready && isUriActionPending()) {
const action = getCachedUriAction();
if (action) {
setUriAction(action);
}
}
return onCachedUriActionChange(setUriAction);
}, [setUriAction]);
}, [setUriAction, ready]);

const onNavigatorReady = useCallback(() => {
RNBootSplash.hide({ fade: true, duration: 500 });
setAppState((state) => ({ ...state, ready: true, locked: showUnlockApplicationScreen }));
}, [setAppState, showUnlockApplicationScreen]);

return (
<NavigationContainer onReady={() => RNBootSplash.hide({ fade: true, duration: 500 })}>
<NavigationContainer onReady={onNavigatorReady}>
<AppLockLogic />
<DesmosPostHogProvider>
<RootNavigator />
Expand Down
1 change: 1 addition & 0 deletions src/recoil/appState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const appStateAtom = atom<AppState>({
key: 'appState',
default: {
locked: false,
ready: false,
noSplashScreen: false,
noLockOnBackground: false,
lastObBlur: undefined,
Expand Down
5 changes: 5 additions & 0 deletions src/types/appState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export interface AppState {
* with the biometrics.
*/
readonly locked: boolean;
/**
* Tells if the application is ready to and the
* splash screen has been hidden.
*/
readonly ready: boolean;
/**
* Tells if the application shouldn't lock when receiving the next on
* background AppState event.
Expand Down

0 comments on commit dc143b5

Please sign in to comment.