diff --git a/ui/pages/reset_email.tsx b/ui/pages/reset_email.tsx index 8a85fa887..34a7232ac 100644 --- a/ui/pages/reset_email.tsx +++ b/ui/pages/reset_email.tsx @@ -36,17 +36,13 @@ const ResetEmail: NextPage = () => { .createBrowserRecoveryFlow({ returnTo: returnTo ? String(returnTo) : undefined, }) - .then(async ({ data }) => { - if (data.request_url !== undefined) { - await router.push( - { - pathname: "reset_email", - query: { flow: data.id }, - }, - `${data.return_to}?flow=${data.id}`, - { shallow: true }, + .then(({ data }) => { + if (flowId !== data.id) { + window.history.replaceState( + null, + "", + `./reset_email?flow=${data.id}`, ); - return; } setFlow(data); }) diff --git a/ui/pages/reset_password.tsx b/ui/pages/reset_password.tsx index 01d9a0ce1..9a411887b 100644 --- a/ui/pages/reset_password.tsx +++ b/ui/pages/reset_password.tsx @@ -51,9 +51,12 @@ const ResetPassword: NextPage = () => { returnTo: returnTo ? String(returnTo) : undefined, }) .then(({ data }) => { - if (data.request_url !== undefined) { - window.location.href = data.request_url; - return; + if (flowId !== data.id) { + window.history.replaceState( + null, + "", + `./reset_password?flow=${data.id}`, + ); } setFlow(data); }) diff --git a/ui/pages/setup_backup_codes.tsx b/ui/pages/setup_backup_codes.tsx index 2294b1996..08ef4559e 100644 --- a/ui/pages/setup_backup_codes.tsx +++ b/ui/pages/setup_backup_codes.tsx @@ -43,9 +43,12 @@ const SetupBackupCodes: NextPage = () => { returnTo: returnTo ? String(returnTo) : undefined, }) .then(({ data }) => { - if (data.request_url !== undefined) { - window.location.href = `./setup_backup_codes?flow=${data.id}`; - return; + if (flowId !== data.id) { + window.history.replaceState( + null, + "", + `./setup_backup_codes?flow=${data.id}`, + ); } setFlow(data); }) diff --git a/ui/pages/setup_passkey.tsx b/ui/pages/setup_passkey.tsx index 0005f5568..7cf84c8d9 100644 --- a/ui/pages/setup_passkey.tsx +++ b/ui/pages/setup_passkey.tsx @@ -43,9 +43,12 @@ const SetupPasskey: NextPage = () => { returnTo: returnTo ? String(returnTo) : undefined, }) .then(({ data }) => { - if (data.request_url !== undefined) { - window.location.href = `./setup_passkey?flow=${data.id}`; - return; + if (flowId !== data.id) { + window.history.replaceState( + null, + "", + `./setup_passkey?flow=${data.id}`, + ); } setFlow(data); }) diff --git a/ui/pages/setup_secure.tsx b/ui/pages/setup_secure.tsx index bd0e15185..8db7511e0 100644 --- a/ui/pages/setup_secure.tsx +++ b/ui/pages/setup_secure.tsx @@ -48,19 +48,15 @@ const SetupSecure: NextPage = () => { ? returnTo.toString() : window.location.pathname.replace("setup_secure", "setup_complete"), }) - .then(async ({ data }) => { - const pwParam = pwChanged ? pwChanged.toString() : "false"; - router.query.flow = data.id; - router.query.pw_changed = pwParam; - - await router.replace( - { - pathname: window.location.pathname, - query: router.query, - }, - undefined, - { shallow: true }, - ); + .then(({ data }) => { + const pwParam = pwChanged ? `&pw_changed=${pwChanged.toString()}` : ""; + if (flowId !== data.id) { + window.history.replaceState( + null, + "", + `./reset_password?flow=${data.id}${pwParam}`, + ); + } setFlow(data); }) .catch(handleFlowError("settings", setFlow))