Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: enforce password check before modal view for recovery phrase #3033

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions ts/components/dialog/SessionSeedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 | boolean>(null);
Expand All @@ -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));
Expand Down
Loading