From d405efbc01cbf8a440f87a16494ec9b3e4be8c73 Mon Sep 17 00:00:00 2001 From: Ryan Miller Date: Wed, 21 Feb 2024 10:44:32 +1100 Subject: [PATCH] fix: enforce password check before modal view for recovery phrase --- ts/components/dialog/SessionSeedModal.tsx | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/ts/components/dialog/SessionSeedModal.tsx b/ts/components/dialog/SessionSeedModal.tsx index ba6eba3a0..c2927301c 100644 --- a/ts/components/dialog/SessionSeedModal.tsx +++ b/ts/components/dialog/SessionSeedModal.tsx @@ -188,7 +188,6 @@ interface ModalInnerProps { const SessionSeedModalInner = (props: ModalInnerProps) => { const { onClickOk } = props; - const [loadingPassword, setLoadingPassword] = useState(true); const [loadingSeed, setLoadingSeed] = useState(true); const [recoveryPhrase, setRecoveryPhrase] = useState(''); const [hasPassword, setHasPassword] = useState(null); @@ -197,30 +196,22 @@ const SessionSeedModalInner = (props: ModalInnerProps) => { const dispatch = useDispatch(); useMount(() => { - async function checkHasPassword() { - if (!loadingPassword) { + async function validateAccess() { + if (passwordHash || recoveryPhrase) { return; } const hash = await Data.getPasswordHash(); setHasPassword(!!hash); setPasswordHash(hash || ''); - setLoadingPassword(false); - } - async function getRecoveryPhrase() { - if (recoveryPhrase) { - return false; - } + const newRecoveryPhrase = getCurrentRecoveryPhrase(); setRecoveryPhrase(newRecoveryPhrase); setLoadingSeed(false); - - return true; } setTimeout(() => (document.getElementById('seed-input-password') as any)?.focus(), 100); - void checkHasPassword(); - void getRecoveryPhrase(); + void validateAccess(); }); const onClose = () => dispatch(recoveryPhraseModal(null));