MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / getImpactTrackingContextFromAuthFlow

Function getImpactTrackingContextFromAuthFlow

apps/web/src/lib/user/server.ts:409–488  ·  view source on GitHub ↗
(requestHeaders?: Headers)

Source from the content-addressed store, hash-verified

407 google_user_image_url: user.image || '',
408 hosted_domain,
409 provider: account.provider,
410 provider_account_id: user.email,
411 display_name: null,
412 };
413}
414
415function createAccountInfo(
416 account: Account,
417 user: NextUser | AdapterUser,
418 profile: Profile | undefined
419): CreateOrUpdateUserArgs {
420 const accountInfo =
421 createGoogleAccountInfo(account, user, profile) ??
422 createAnacondaAccountInfo(account, user) ??
423 createAppleAccountInfo(account, user) ??
424 createGitHubAccountInfo(account, user, profile) ??
425 createGitlabAccountInfo(account, user) ??
426 createLinkedInAccountInfo(account, user) ??
427 createDiscordAccountInfo(account, user) ??
428 createEmailAccountInfo(account, user) ??
429 createFakeAccountInfo(account, user) ??
430 createSSOAccountInfo(account, user, profile);
431
432 if (!accountInfo) {
433 throw new Error(`Unsupported provider: ${account.provider}`);
434 }
435
436 return accountInfo;
437}
438
439export type SignInRedirectContext = {
440 callbackPath?: string;
441 signup?: boolean;
442};
443
444/**
445 * Extracts the sign-in redirect context from the NextAuth callback-url cookie
446 * value. Exported so the parsing logic can be tested without mocking the
447 * next/headers cookie store.
448 *
449 * The NextAuth callback-url cookie holds the post-auth destination, e.g.
450 * `/users/after-sign-in?callbackPath=/device-auth?code=<CODE>`. We lift
451 * `callbackPath` and `signup` out so that bouncing back to `/users/sign_in`
452 * on an auth error preserves the mobile device-auth context and the signup
453 * UI mode the user originally requested.
454 */
455export function parseSignInRedirectContext(
456 callbackUrlCookieValue: string | undefined
457): SignInRedirectContext {
458 if (!callbackUrlCookieValue) return {};
459
460 let callbackUrl: URL;
461 try {
462 callbackUrl = new URL(callbackUrlCookieValue, 'http://localhost');
463 } catch {
464 return {};
465 }
466

Callers 1

signInFunction · 0.85

Calls 7

logImpactReferralDebugFunction · 0.90
localeFromHeadersFunction · 0.90
countryCodeFromHeadersFunction · 0.90
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected