(props: OnboardingProps)
| 30 | } |
| 31 | |
| 32 | export default async function Onboarding(props: OnboardingProps) { |
| 33 | const searchParams = await props.searchParams; |
| 34 | const org = await __unsafePrisma.org.findUnique({ where: { id: SINGLE_TENANT_ORG_ID } }); |
| 35 | const session = await auth(); |
| 36 | |
| 37 | if (!org) { |
| 38 | return <div>Error loading organization</div>; |
| 39 | } |
| 40 | |
| 41 | if (org && org.isOnboarded) { |
| 42 | redirect('/'); |
| 43 | } |
| 44 | |
| 45 | // Check if user is authenticated but not the owner |
| 46 | if (session?.user) { |
| 47 | if (org) { |
| 48 | const membership = await __unsafePrisma.userToOrg.findUnique({ |
| 49 | where: { |
| 50 | orgId_userId: { |
| 51 | orgId: org.id, |
| 52 | userId: session.user.id |
| 53 | } |
| 54 | } |
| 55 | }); |
| 56 | |
| 57 | if (!membership || membership.role !== OrgRole.OWNER) { |
| 58 | return <NonOwnerOnboardingMessage />; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // If we're using an IAP bridge we need to sign them in now and then redirect them back to the onboarding page |
| 64 | const ssoEntitlement = await hasEntitlement("sso"); |
| 65 | if (ssoEntitlement && env.AUTH_EE_GCP_IAP_ENABLED && env.AUTH_EE_GCP_IAP_AUDIENCE) { |
| 66 | return <GcpIapAuth callbackUrl={`/onboard`} />; |
| 67 | } |
| 68 | |
| 69 | // Determine current step based on URL parameter and authentication state |
| 70 | const stepParam = searchParams?.step ? parseInt(searchParams.step) : 0; |
| 71 | const currentStep = session?.user ? Math.max(2, stepParam) : Math.max(0, Math.min(stepParam, 1)); |
| 72 | |
| 73 | const isLicensed = await isValidLicenseActive(); |
| 74 | |
| 75 | const steps: OnboardingStep[] = []; |
| 76 | |
| 77 | steps.push({ |
| 78 | id: "welcome", |
| 79 | title: "Welcome to Sourcebot", |
| 80 | subtitle: "This onboarding flow will guide you through creating your owner account and configuring your organization.", |
| 81 | component: <WelcomeStep nextStep={steps.length + 1} />, |
| 82 | }); |
| 83 | |
| 84 | steps.push({ |
| 85 | id: "owner-signup", |
| 86 | title: "Create Owner Account", |
| 87 | subtitle: ( |
| 88 | <> |
| 89 | Use your preferred authentication method to create your owner account. To set up additional authentication providers, check out our{" "} |
nothing calls this directly
no test coverage detected