From 15c0a9ccd4d0415112fd540e3b234ed588fe6eda Mon Sep 17 00:00:00 2001 From: First-Terraner Date: Sun, 9 Jul 2023 16:49:25 +0200 Subject: [PATCH] update after commit --- src/components/App.tsx | 12 +++++------- src/components/screens/Auth/index.tsx | 16 ++++++++-------- src/components/screens/Settings/Security.tsx | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index e4d028ec..7bc6cc99 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -84,7 +84,7 @@ function _App() { const handlePinForeground = async () => { // check if app is locked const now = Math.ceil(Date.now() / 1000) - const lockData = await store.getObj('lock') + const lockData = await store.getObj('auth:lock') if (lockData) { // set state acccording to lockData timestamp const secsPassed = now - lockData.timestamp @@ -96,7 +96,7 @@ function _App() { }) } // handle app was longer than 5 mins in the background - const bgTimestamp = await store.get('authBg') + const bgTimestamp = await store.get('auth:bg') if (isStr(bgTimestamp) && bgTimestamp.length > 0) { if (now - +bgTimestamp > FiveMins) { setBgAuth(true) @@ -256,10 +256,8 @@ function _App() { } } async function initAuth() { - // await secureStore.delete('pin') - // await store.delete('pinSkipped') - const skipped = await store.get('pinSkipped') - const pinHash = await secureStore.get('pin') + const skipped = await store.get('auth:skipped') + const pinHash = await secureStore.get('auth:pin') setAuth({ shouldAuth: isNull(pinHash) ? '' : pinHash, shouldSetup: !isStr(skipped) || !skipped.length @@ -307,7 +305,7 @@ function _App() { } else { l('App has gone to the background!') // store timestamp to activate auth after > 5mins in background - await store.set('authBg', `${Math.ceil(Date.now() / 1000)}`) + await store.set('auth:bg', `${Math.ceil(Date.now() / 1000)}`) } appState.current = nextAppState }) diff --git a/src/components/screens/Auth/index.tsx b/src/components/screens/Auth/index.tsx index 73d0a085..c359fdb1 100644 --- a/src/components/screens/Auth/index.tsx +++ b/src/components/screens/Auth/index.tsx @@ -64,7 +64,7 @@ export default function AuthPage({ navigation, route }: TAuthPageProps) { } // store this info to avoid bypass state on app restart if (!isConfirm) { - await store.setObj('lock', { ...attemptState, timestamp: Math.ceil(Date.now() / 1000) }) + await store.setObj('auth:lock', { ...attemptState, timestamp: Math.ceil(Date.now() / 1000) }) } setAttempts(attemptState) // reset mismatch state @@ -97,15 +97,15 @@ export default function AuthPage({ navigation, route }: TAuthPageProps) { // user wants to delete his PIN if (shouldRemove) { await Promise.all([ - secureStore.delete('pin'), - store.set('pinSkipped', '1') + secureStore.delete('auth:pin'), + store.set('auth:skipped', '1') ]) setAuth('') } // remove the lock data and authbg in storage await Promise.all([ - store.delete('lock'), - store.delete('authBg') + store.delete('auth:lock'), + store.delete('auth:bg') ]) resetStates() // User wants to edit his PIN, do not navigate away, just update the state as he had no PIN so he can enter a new PIN @@ -129,8 +129,8 @@ export default function AuthPage({ navigation, route }: TAuthPageProps) { // else: PIN confirm is matching const hash = hash256(pinStr) await Promise.all([ - secureStore.set('pin', hash), - store.delete('lock') + secureStore.set('auth:pin', hash), + store.delete('auth:lock') ]) resetStates() setSuccess(true) @@ -172,7 +172,7 @@ export default function AuthPage({ navigation, route }: TAuthPageProps) { return } // skip pin setup - await store.set('pinSkipped', '1') + await store.set('auth:skipped', '1') navigation.navigate('dashboard') } // conditional rendering dots of pin input diff --git a/src/components/screens/Settings/Security.tsx b/src/components/screens/Settings/Security.tsx index 5aff27be..605fe888 100644 --- a/src/components/screens/Settings/Security.tsx +++ b/src/components/screens/Settings/Security.tsx @@ -35,7 +35,7 @@ export default function SecuritySettings({ navigation, route }: TSecuritySetting } } const handlePin = async () => { - const pinHash = await secureStore.get('pin') + const pinHash = await secureStore.get('auth:pin') setPin(isNull(pinHash) ? '' : pinHash) } useEffect(() => void handlePin(), [])