🐛 Fix guard generate redirect uri ignore query strings
This commit is contained in:
parent
ae915babe6
commit
e5641b8068
@ -21,15 +21,16 @@ export default function RootLayout(props: any) {
|
|||||||
}, [ready, userinfo]);
|
}, [ready, userinfo]);
|
||||||
|
|
||||||
function keepGate(path: string, e?: BeforeLeaveEventArgs) {
|
function keepGate(path: string, e?: BeforeLeaveEventArgs) {
|
||||||
|
const pathname = path.split("?")[0];
|
||||||
const whitelist = ["/auth/login", "/auth/register", "/users/me/confirm"];
|
const whitelist = ["/auth/login", "/auth/register", "/users/me/confirm"];
|
||||||
|
|
||||||
if (!userinfo?.isLoggedIn && !whitelist.includes(path)) {
|
if (!userinfo?.isLoggedIn && !whitelist.includes(pathname)) {
|
||||||
if (!e?.defaultPrevented) e?.preventDefault();
|
if (!e?.defaultPrevented) e?.preventDefault();
|
||||||
navigate(`/auth/login?redirect_uri=${path}`);
|
navigate(`/auth/login?redirect_uri=${encodeURIComponent(path)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useBeforeLeave((e: BeforeLeaveEventArgs) => keepGate(e.to.toString().split("?")[0], e));
|
useBeforeLeave((e: BeforeLeaveEventArgs) => keepGate(e.to.toString(), e));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Show when={ready()} fallback={
|
<Show when={ready()} fallback={
|
||||||
|
@ -89,7 +89,7 @@ export default function LoginPage() {
|
|||||||
if (data["is_finished"]) {
|
if (data["is_finished"]) {
|
||||||
await grantToken(data["session"]["grant_token"]);
|
await grantToken(data["session"]["grant_token"]);
|
||||||
await readProfiles();
|
await readProfiles();
|
||||||
navigate(searchParams["redirect_uri"] ?? "/");
|
navigate(searchParams["redirect_uri"] ? decodeURIComponent(searchParams["redirect_uri"]) : "/");
|
||||||
} else {
|
} else {
|
||||||
setError(null);
|
setError(null);
|
||||||
setStage("choosing");
|
setStage("choosing");
|
||||||
|
Loading…
Reference in New Issue
Block a user