File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,17 @@ export default async function OnboardingLayout({
1313 redirect ( "/signin" ) ;
1414 }
1515
16- const workspaceId = session . user . workspaceId ;
16+ // The session JWT may not yet reflect a workspace that was just linked.
17+ // Fall back to a direct DB lookup for email auth users.
18+ let workspaceId = session . user . workspaceId ;
19+
20+ if ( ! workspaceId && session . user . authType === "email" ) {
21+ const dbUser = await prisma . user . findUnique ( {
22+ where : { id : session . user . id } ,
23+ select : { workspaceId : true } ,
24+ } ) ;
25+ workspaceId = dbUser ?. workspaceId ?? undefined ;
26+ }
1727
1828 if ( workspaceId ) {
1929 const workspace = await prisma . workspace . findUnique ( {
Original file line number Diff line number Diff line change 11import { auth } from "@/lib/auth" ;
22import { redirect } from "next/navigation" ;
3+ import prisma from "@/lib/prisma" ;
34import { OnboardingWizard } from "./onboarding-wizard" ;
45
56export default async function OnboardingPage ( ) {
@@ -9,11 +10,23 @@ export default async function OnboardingPage() {
910 redirect ( "/signin" ) ;
1011 }
1112
13+ // The session JWT may not yet reflect a workspace that was just linked
14+ // (e.g. after the Slack OAuth callback). Fall back to a direct DB lookup.
15+ let workspaceId = session . user . workspaceId ;
16+
17+ if ( ! workspaceId && session . user . authType === "email" ) {
18+ const dbUser = await prisma . user . findUnique ( {
19+ where : { id : session . user . id } ,
20+ select : { workspaceId : true } ,
21+ } ) ;
22+ workspaceId = dbUser ?. workspaceId ?? undefined ;
23+ }
24+
1225 return (
1326 < OnboardingWizard
1427 authType = { session . user . authType }
1528 userId = { session . user . id }
16- workspaceId = { session . user . workspaceId }
29+ workspaceId = { workspaceId }
1730 />
1831 ) ;
1932}
You can’t perform that action at this time.
0 commit comments