Compare commits

...

1 Commits

Author SHA1 Message Date
Jiang Bohan
c67266ccbf fix(auth): honor ?next= redirect through Google OAuth flow
The login page now encodes the ?next= param into the Google OAuth state
so the auth callback can redirect to the right destination (e.g.
/invite/{id}) after login, instead of always going to /issues.
2026-04-15 00:49:51 +08:00
2 changed files with 18 additions and 4 deletions

View File

@@ -37,6 +37,15 @@ function LoginPageContent() {
router.push(ws ? nextUrl : "/onboarding");
};
// Build Google OAuth state: encode platform + next URL so the callback
// can redirect to the right place after login.
const googleState = [
platform === "desktop" ? "platform:desktop" : "",
nextUrl !== "/issues" ? `next:${nextUrl}` : "",
]
.filter(Boolean)
.join(",") || undefined;
return (
<LoginPage
onSuccess={handleSuccess}
@@ -45,7 +54,7 @@ function LoginPageContent() {
? {
clientId: googleClientId,
redirectUri: `${window.location.origin}/auth/callback`,
state: platform === "desktop" ? "platform:desktop" : undefined,
state: googleState,
}
: undefined
}

View File

@@ -39,8 +39,11 @@ function CallbackContent() {
return;
}
const state = searchParams.get("state");
const isDesktop = state === "platform:desktop";
const state = searchParams.get("state") || "";
const stateParts = state.split(",");
const isDesktop = stateParts.includes("platform:desktop");
const nextPart = stateParts.find((p) => p.startsWith("next:"));
const nextUrl = nextPart ? nextPart.slice(5) : null; // strip "next:" prefix
const redirectUri = `${window.location.origin}/auth/callback`;
@@ -63,7 +66,9 @@ function CallbackContent() {
qc.setQueryData(workspaceKeys.list(), wsList);
const lastWsId = localStorage.getItem("multica_workspace_id");
const ws = await hydrateWorkspace(wsList, lastWsId);
router.push(ws ? "/issues" : "/onboarding");
// Honor the ?next= redirect if present (e.g. /invite/{id})
const defaultDest = ws ? "/issues" : "/onboarding";
router.push(nextUrl || defaultDest);
})
.catch((err) => {
setError(err instanceof Error ? err.message : "Login failed");