Skip to content

Commit

Permalink
Replace router history in some navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiSugiura committed Dec 18, 2024
1 parent 3c08376 commit 6106c49
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/keychain/src/components/authenticate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function Authenticate() {
setParams({ name, action, network });

// Remove query params to avoid issues with password managers
navigate(".");
navigate(".", { replace: true });
}
}, [params, searchParams, navigate]);

Expand Down
7 changes: 4 additions & 3 deletions packages/keychain/src/components/session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function Session() {
const onCallback = useCallback(
async (response: SessionResponse) => {
if (!queries.callback_uri && !queries.redirect_uri) {
navigate("/failure");
navigate("/failure", { replace: true });
return;
}

Expand Down Expand Up @@ -84,12 +84,13 @@ export function Session() {
title: "Session Registered!",
description: "Return to your terminal to continue",
}.toString()}`,
{ replace: true },
);
return;
}
} catch (e) {
console.error("failed to call the callback url", e);
navigate("/failure");
navigate("/failure", { replace: true });
}

return;
Expand All @@ -98,7 +99,7 @@ export function Session() {
if (queries.redirect_uri) {
const url = decodeURIComponent(queries.redirect_uri);
const query_name = queries.redirect_query_name ?? "session";
navigate(`${url}?${query_name}=${encodedResponse}`);
navigate(`${url}?${query_name}=${encodedResponse}`, { replace: true });
}
},
[navigate, queries],
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/slot/consent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function Consent() {

useEffect(() => {
if (!Controller.fromStore(import.meta.env.VITE_ORIGIN!)) {
navigate("/slot");
navigate("/slot", { replace: true });
}
}, [navigate]);

Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/slot/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Auth() {
"",
);

navigate(`/slot/consent${query}`);
navigate(`/slot/consent${query}`, { replace: true });
}
}, [user, controller, navigate, searchParams]);

Expand Down

0 comments on commit 6106c49

Please sign in to comment.