Skip to content

Commit

Permalink
update after commit
Browse files Browse the repository at this point in the history
  • Loading branch information
KKA11010 committed Jul 9, 2023
1 parent dd57cf7 commit 15c0a9c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 5 additions & 7 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ILockData>('lock')
const lockData = await store.getObj<ILockData>('auth:lock')
if (lockData) {
// set state acccording to lockData timestamp
const secsPassed = now - lockData.timestamp
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
})
Expand Down
16 changes: 8 additions & 8 deletions src/components/screens/Auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/components/screens/Settings/Security.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(), [])
Expand Down

0 comments on commit 15c0a9c

Please sign in to comment.