Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(auth): honor ?next= redirect through Google OAuth flow (#1024)
Bohan Jiangc79cfaf330ec
diff --git a/apps/web/app/(auth)/login/page.tsx b/apps/web/app/(auth)/login/page.tsxindex ea0c54c352..78de1dd63e 100644--- a/apps/web/app/(auth)/login/page.tsx+++ b/apps/web/app/(auth)/login/page.tsx@@ -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 (<LoginPageonSuccess={handleSuccess}@@ -45,7 +54,7 @@ function LoginPageContent() {? {clientId: googleClientId,redirectUri: `${window.location.origin}/auth/callback`,- state: platform === "desktop" ? "platform:desktop" : undefined,+ state: googleState,}: undefined}diff --git a/apps/web/app/auth/callback/page.tsx b/apps/web/app/auth/callback/page.tsxindex 41993d083a..31f437961f 100644--- a/apps/web/app/auth/callback/page.tsx+++ b/apps/web/app/auth/callback/page.tsx@@ -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:" prefixconst 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");