11'use client' ;
22
33import { AppIcon } from "@/components/app-square" ;
4- import { useRouter } from "@/components/router" ;
54import { DesignAlert } from "@/components/design-components/alert" ;
65import { DesignBadge } from "@/components/design-components/badge" ;
76import { DesignButton } from "@/components/design-components/button" ;
87import { DesignCard } from "@/components/design-components/card" ;
98import { DesignInput } from "@/components/design-components/input" ;
109import { DesignSelectorDropdown } from "@/components/design-components/select" ;
10+ import { useRouter } from "@/components/router" ;
1111import {
1212 Alert ,
1313 AlertDescription ,
1414 AlertTitle ,
15- Button ,
1615 BrowserFrame ,
16+ Button ,
1717 Card ,
1818 CardContent ,
1919 CardDescription ,
@@ -26,12 +26,12 @@ import {
2626 DialogHeader ,
2727 DialogTitle ,
2828 Label ,
29- Spinner ,
3029 Select ,
3130 SelectContent ,
3231 SelectItem ,
3332 SelectTrigger ,
3433 SelectValue ,
34+ Spinner ,
3535 Switch ,
3636 Tooltip ,
3737 TooltipContent ,
@@ -40,35 +40,31 @@ import {
4040 Typography ,
4141 cn ,
4242} from "@/components/ui" ;
43- import { getPublicEnvVar } from "@/lib/env" ;
4443import { useUpdateConfig } from "@/lib/config-update" ;
44+ import { getPublicEnvVar } from "@/lib/env" ;
4545import { stackAppInternalsSymbol } from "@/lib/stack-app-internals" ;
4646import {
4747 ArrowLeftIcon ,
48- ArrowRightIcon ,
4948 ArrowsClockwiseIcon ,
5049 ChartBarIcon ,
5150 CheckCircleIcon ,
52- CircleIcon ,
53- GlobeIcon ,
5451 LightningIcon ,
5552 LinkBreakIcon ,
5653 PlusCircleIcon ,
5754 ShieldIcon ,
5855 StripeLogoIcon ,
5956 WalletIcon ,
6057 WarningCircleIcon ,
61- WebhooksLogoIcon ,
58+ WebhooksLogoIcon
6259} from "@phosphor-icons/react" ;
6360import { AdminOwnedProject , AuthPage , useStackApp , useUser } from "@stackframe/stack" ;
64- import { previewTemplateSource } from "@stackframe/stack-shared/dist/helpers/emails" ;
6561import { ALL_APPS , type AppId } from "@stackframe/stack-shared/dist/apps/apps-config" ;
62+ import { previewTemplateSource } from "@stackframe/stack-shared/dist/helpers/emails" ;
6663import { projectOnboardingStatusValues , type ProjectOnboardingStatus } from "@stackframe/stack-shared/dist/schema-fields" ;
6764import { captureError } from "@stackframe/stack-shared/dist/utils/errors" ;
68- import { runAsynchronouslyWithAlert , wait } from "@stackframe/stack-shared/dist/utils/promises" ;
6965import { allProviders } from "@stackframe/stack-shared/dist/utils/oauth" ;
66+ import { runAsynchronouslyWithAlert , wait } from "@stackframe/stack-shared/dist/utils/promises" ;
7067import { stringCompare } from "@stackframe/stack-shared/dist/utils/strings" ;
71- import { generateUuid } from "@stackframe/stack-shared/dist/utils/uuids" ;
7268import { useSearchParams } from "next/navigation" ;
7369import { useCallback , useEffect , useMemo , useRef , useState } from "react" ;
7470
@@ -176,7 +172,7 @@ function buildTimeline(includePayments: boolean): TimelineStep[] {
176172 return timeline ;
177173}
178174
179- function deriveInitialSignInMethods ( project : AdminOwnedProject ) : Set < SignInMethod > {
175+ function deriveInitialSignInMethods ( project : AdminOwnedProject , status : ProjectOnboardingStatus ) : Set < SignInMethod > {
180176 const config = project . config ;
181177 const methods = new Set < SignInMethod > ( ) ;
182178
@@ -196,6 +192,23 @@ function deriveInitialSignInMethods(project: AdminOwnedProject): Set<SignInMetho
196192 }
197193 }
198194
195+ const hasDefaultUntouchedAuthConfig = (
196+ config . credentialEnabled
197+ && ! config . magicLinkEnabled
198+ && ! config . passkeyEnabled
199+ && config . oauthProviders . length === 0
200+ ) ;
201+ const isInEarlyOnboardingStep = (
202+ status === "config_choice"
203+ || status === "apps_selection"
204+ || status === "auth_setup"
205+ ) ;
206+ if ( hasDefaultUntouchedAuthConfig && isInEarlyOnboardingStep ) {
207+ methods . add ( "credential" ) ;
208+ methods . add ( "magicLink" ) ;
209+ methods . add ( "google" ) ;
210+ }
211+
199212 return methods ;
200213}
201214
@@ -481,7 +494,7 @@ function ProjectOnboardingWizard(props: {
481494 const finishProjectOnboarding = onComplete ;
482495 const [ saving , setSaving ] = useState ( false ) ;
483496 const [ selectedApps , setSelectedApps ] = useState < Set < AppId > > ( ( ) => deriveInitialApps ( completeConfig ) ) ;
484- const [ signInMethods , setSignInMethods ] = useState < Set < SignInMethod > > ( ( ) => deriveInitialSignInMethods ( project ) ) ;
497+ const [ signInMethods , setSignInMethods ] = useState < Set < SignInMethod > > ( ( ) => deriveInitialSignInMethods ( project , status ) ) ;
485498 const [ trustedDomain , setTrustedDomain ] = useState ( "" ) ;
486499 const [ domainHandlerPath , setDomainHandlerPath ] = useState ( "/handler" ) ;
487500 const [ managedSubdomain , setManagedSubdomain ] = useState ( "" ) ;
@@ -509,7 +522,7 @@ function ProjectOnboardingWizard(props: {
509522 previousProjectId . current = project . id ;
510523
511524 setSelectedApps ( deriveInitialApps ( completeConfig ) ) ;
512- setSignInMethods ( deriveInitialSignInMethods ( project ) ) ;
525+ setSignInMethods ( deriveInitialSignInMethods ( project , status ) ) ;
513526
514527 const trustedDomains = Object . values ( completeConfig . domains . trustedDomains )
515528 . filter ( ( entry ) => entry . baseUrl != null )
@@ -534,7 +547,7 @@ function ProjectOnboardingWizard(props: {
534547 setManagedDomainSetupStatus ( null ) ;
535548 setRequiredAppsNotice ( null ) ;
536549 setSelectedConfigChoice ( "create-new" ) ;
537- } , [ completeConfig , project , project . id ] ) ;
550+ } , [ completeConfig , project , project . id , status ] ) ;
538551
539552 const emailThemes = project . app . useEmailThemes ( ) ;
540553 const includePayments = selectedApps . has ( "payments" ) || status === "payments_setup" || completeConfig . apps . installed . payments ?. enabled === true ;
0 commit comments