Skip to content

Commit

Permalink
fix Unlock Wallet route (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 authored Aug 21, 2024
1 parent d8f1344 commit 0292afd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/features/src/lock/routes/unlock-wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const formSchema = z.object({
export const UnlockWalletRoute = () => {
const [restartAlertVisible, setRestartAlertVisible] = useState(false)
const [showPassword, setShowPassword] = useState(false)
const [formSubmitted, setFormSubmitted] = useState(false)
const navigate = useNavigate()
const unlockWalletForm = useForm({
defaultValues: {
Expand All @@ -29,6 +30,7 @@ export const UnlockWalletRoute = () => {
}: {
spendingPassword: string
}) => {
setFormSubmitted(true)
await sessionPersistence.setItem("spendingPassword", spendingPassword)
await useVault.persist.rehydrate()
setTimeout(() => {
Expand All @@ -45,6 +47,7 @@ export const UnlockWalletRoute = () => {
// biome-ignore lint: won't update
useEffect(() => {
const unsub = useVault.persist?.onFinishHydration(async () => {
if (!formSubmitted) return
const authenticated = (await securePersistence.getItem("foo")) === "bar"
if (!authenticated) {
await sessionPersistence.removeItem("spendingPassword")
Expand All @@ -56,7 +59,7 @@ export const UnlockWalletRoute = () => {
navigate("/dashboard")
})
return () => unsub?.()
}, [])
}, [formSubmitted])
return (
<UnlockWalletView
form={unlockWalletForm}
Expand Down

0 comments on commit 0292afd

Please sign in to comment.