diff --git a/packages/features/src/lock/views/unlock-wallet.tsx b/packages/features/src/lock/views/unlock-wallet.tsx index 8f71c9fa..be92020a 100644 --- a/packages/features/src/lock/views/unlock-wallet.tsx +++ b/packages/features/src/lock/views/unlock-wallet.tsx @@ -5,7 +5,7 @@ import { } from '@palladxyz/persistence' import { useVault } from '@palladxyz/vault' import { EyeIcon, EyeOffIcon } from 'lucide-react' -import { useEffect, useState } from 'react' +import { FormEvent, useEffect, useState } from 'react' import { useForm } from 'react-hook-form' import { useNavigate } from 'react-router-dom' import { z } from 'zod' @@ -59,6 +59,10 @@ export const UnlockWalletView = () => { }) }, 100) } + const togglePassword = (event: FormEvent) => { + event.preventDefault() + setShowPassword(!showPassword) + } useEffect(() => { const unsub = useVault.persist.onFinishHydration(async () => { const authenticated = @@ -127,7 +131,7 @@ export const UnlockWalletView = () => { variant="outline" size="icon" data-testid="unlockWallet__togglePasswordVisible" - onClick={() => setShowPassword(!showPassword)} + onClick={togglePassword} > {showPassword ? : } diff --git a/packages/features/src/onboarding/views/start.tsx b/packages/features/src/onboarding/views/start.tsx index 86923543..1fc21522 100644 --- a/packages/features/src/onboarding/views/start.tsx +++ b/packages/features/src/onboarding/views/start.tsx @@ -17,12 +17,21 @@ export const StartView = () => { useEffect(() => { const initialRedirect = async () => { if (!isStoreInitialized) return setAppInitialized(true) - const spendingPassword = - (await getSessionPersistence().getItem('spendingPassword')) || '' - const spendingPasswordSet = spendingPassword.length > 0 + let spendingPassword + try { + spendingPassword = + (await getSessionPersistence().getItem('spendingPassword')) || '' + } catch { + return navigate('/unlock') + } + const spendingPasswordSet = spendingPassword?.length > 0 if (!spendingPasswordSet) return navigate('/unlock') - const authenticated = - (await getSecurePersistence().getItem('foo')) === 'bar' + let authenticated + try { + authenticated = (await getSecurePersistence().getItem('foo')) === 'bar' + } catch { + authenticated = false + } if (!authenticated) return navigate('/unlock') return navigate('/dashboard') }