MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / Onboard

Function Onboard

web/src/app/onboard/page.tsx:32–177  ·  view source on GitHub ↗
({ searchParams }: PageProps)

Source from the content-addressed store, hash-verified

30}
31
32const Onboard = async ({ searchParams }: PageProps) => {
33 const resolvedSearchParams = searchParams ? await searchParams : {}
34 const authCode = resolvedSearchParams.auth_code
35 const session = await getServerSession(authOptions)
36 const user = session?.user
37
38 if (!user) {
39 const params = new URLSearchParams()
40 if (authCode) params.set('auth_code', authCode)
41 const query = params.toString()
42 return redirect(
43 query ? `/login?${query}` : env.NEXT_PUBLIC_CODEBUFF_APP_URL,
44 )
45 }
46
47 if (!authCode) {
48 return (
49 <WelcomeCard
50 fallbackTitle="Welcome to Codebuff!"
51 description=""
52 message="You're all set! Head back to your terminal to continue."
53 />
54 )
55 }
56
57 const authCodeResolution = await resolveCliAuthCode(
58 authCode,
59 consumeCliAuthCodeToken,
60 )
61
62 if (authCodeResolution.status === 'already_consumed') {
63 return (
64 <CardWithBeams
65 title="This login link was already used"
66 description="Return to your terminal to continue, or restart Codebuff if it is still waiting for login."
67 content={<p>You can close this browser window.</p>}
68 />
69 )
70 }
71
72 if (authCodeResolution.status === 'missing') {
73 return (
74 <CardWithBeams
75 title="This login link has expired"
76 description="Return to your terminal and restart Codebuff to generate a new login link."
77 content={<p>You can close this browser window.</p>}
78 />
79 )
80 }
81
82 const { authCode: resolvedAuthCode } = authCodeResolution
83 const { fingerprintId, expiresAt, receivedHash } =
84 parseAuthCode(resolvedAuthCode)
85 const { valid, expectedHash: fingerprintHash } = validateAuthCode(
86 receivedHash,
87 fingerprintId,
88 expiresAt,
89 env.NEXTAUTH_SECRET,

Callers

nothing calls this directly

Calls 10

resolveCliAuthCodeFunction · 0.90
parseAuthCodeFunction · 0.90
validateAuthCodeFunction · 0.90
isAuthCodeExpiredFunction · 0.90
hasCliSessionForAuthHashFunction · 0.90
checkFingerprintConflictFunction · 0.90
createCliSessionFunction · 0.90
setMethod · 0.80
redirectFunction · 0.50

Tested by

no test coverage detected