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(request) avoid using request url in the ui. fixes #289 #298

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
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
16 changes: 6 additions & 10 deletions ui/pages/reset_email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
Expand Down
9 changes: 6 additions & 3 deletions ui/pages/reset_password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
Expand Down
9 changes: 6 additions & 3 deletions ui/pages/setup_backup_codes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
Expand Down
9 changes: 6 additions & 3 deletions ui/pages/setup_passkey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
Expand Down
22 changes: 9 additions & 13 deletions ui/pages/setup_secure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
nsklikas marked this conversation as resolved.
Show resolved Hide resolved
null,
"",
`./reset_password?flow=${data.id}${pwParam}`,
);
}
setFlow(data);
})
.catch(handleFlowError("settings", setFlow))
Expand Down
Loading