🐛 Fix guard generate redirect uri ignore query strings
This commit is contained in:
		| @@ -21,15 +21,16 @@ export default function RootLayout(props: any) { | ||||
|   }, [ready, userinfo]); | ||||
|  | ||||
|   function keepGate(path: string, e?: BeforeLeaveEventArgs) { | ||||
|     const pathname = path.split("?")[0]; | ||||
|     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(); | ||||
|       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 ( | ||||
|     <Show when={ready()} fallback={ | ||||
|   | ||||
| @@ -89,7 +89,7 @@ export default function LoginPage() { | ||||
|         if (data["is_finished"]) { | ||||
|           await grantToken(data["session"]["grant_token"]); | ||||
|           await readProfiles(); | ||||
|           navigate(searchParams["redirect_uri"] ?? "/"); | ||||
|           navigate(searchParams["redirect_uri"] ? decodeURIComponent(searchParams["redirect_uri"]) : "/"); | ||||
|         } else { | ||||
|           setError(null); | ||||
|           setStage("choosing"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user