diff --git a/hub/src/admin/routes/authRoutes.ts b/hub/src/admin/routes/authRoutes.ts index fe8b54e..a7e4fb2 100644 --- a/hub/src/admin/routes/authRoutes.ts +++ b/hub/src/admin/routes/authRoutes.ts @@ -433,8 +433,10 @@ async function resolvePostLoginRedirect( }); if (intended === null) return "/admin?error=not_an_active_org_member"; const orgRoot = `/admin/org/${intended.organization.slug}`; + // Default / missing returnTo sanitizes to "/admin". Always land in the org + // admin SPA (not the legacy static "close this tab" complete page). if (returnTo === "/admin") { - return `/auth/feishu/complete?org=${encodeURIComponent(intended.organization.name)}`; + return orgRoot; } return returnTo === orgRoot || returnTo.startsWith(`${orgRoot}/`) ? returnTo : orgRoot; } diff --git a/hub/test/integration/admin-auth.test.ts b/hub/test/integration/admin-auth.test.ts index 1aa5fe9..695162f 100644 --- a/hub/test/integration/admin-auth.test.ts +++ b/hub/test/integration/admin-auth.test.ts @@ -346,14 +346,7 @@ describe("admin auth + org API guards", () => { headers: { cookie: cookiePair(defaultStart.headers["set-cookie"], OAUTH_STATE_COOKIE_NAME) }, }); expect(defaultCallback.statusCode).toBe(302); - expect(defaultCallback.headers.location).toBe( - "/auth/feishu/complete?org=Test%20Default%20Organization", - ); - const complete = await app.inject({ method: "GET", url: defaultCallback.headers.location! }); - expect(complete.statusCode).toBe(200); - expect(complete.headers["content-type"]).toContain("text/html"); - expect(complete.body).toContain("登录并加入组织成功"); - expect(complete.body).toContain("Test Default Organization"); + expect(defaultCallback.headers.location).toBe("/admin/org/test-default"); await connections.disable({ organizationId: DEFAULT_ORG_ID, actorUserId: "scoped-owner" }); const revoked = await app.inject({ method: "GET", url: "/api/me", headers: { cookie: sessionCookie } });