diff --git a/ui/app/api/auth/callback/github/route.ts b/ui/app/api/auth/callback/github/route.ts index 7f97dbd973..2dd3aa0bce 100644 --- a/ui/app/api/auth/callback/github/route.ts +++ b/ui/app/api/auth/callback/github/route.ts @@ -46,7 +46,8 @@ export async function GET(req: Request) { const { access, refresh } = data.data.attributes; try { - const redirectPath = callbackPath; + // Invitation tokens are accepted during the social token exchange. + const redirectPath = invitationToken ? "/" : callbackPath; const result = await signIn("social-oauth", { accessToken: access, refreshToken: refresh, diff --git a/ui/app/api/auth/callback/google/route.ts b/ui/app/api/auth/callback/google/route.ts index 8bf4bf7159..022d2e9fe9 100644 --- a/ui/app/api/auth/callback/google/route.ts +++ b/ui/app/api/auth/callback/google/route.ts @@ -46,7 +46,8 @@ export async function GET(req: Request) { const { access, refresh } = data.data.attributes; try { - const redirectPath = callbackPath; + // Invitation tokens are accepted during the social token exchange. + const redirectPath = invitationToken ? "/" : callbackPath; const result = await signIn("social-oauth", { accessToken: access, refreshToken: refresh,