import { Metadata } from 'next'; import Link from 'next/link'; import { redirect } from 'next/navigation'; import type { Provider } from '@supabase/supabase-js'; import { LinkAccountsList } from '@kit/accounts/personal-account-settings'; import { AuthLayoutShell } from '@kit/auth/shared'; import { requireUser } from '@kit/supabase/require-user'; import { getSupabaseServerClient } from '@kit/supabase/server-client'; import { Button } from '@kit/ui/button'; import { Heading } from '@kit/ui/heading'; import { Trans } from '@kit/ui/trans'; import { AppLogo } from '~/components/app-logo'; import authConfig from '~/config/auth.config'; import pathsConfig from '~/config/paths.config'; import { createI18nServerInstance } from '~/lib/i18n/i18n.server'; import { withI18n } from '~/lib/i18n/with-i18n'; export const meta = async (): Promise => { const i18n = await createI18nServerInstance(); return { title: i18n.t('auth:setupAccount'), }; }; type IdentitiesPageProps = { searchParams: Promise<{ next?: string }>; }; /** * @name IdentitiesPage * @description Displays linked accounts and available authentication methods. */ async function IdentitiesPage(props: IdentitiesPageProps) { const { nextPath, showPasswordOption, showEmailOption, oAuthProviders, enableIdentityLinking, } = await fetchData(props); return (
); } export default withI18n(IdentitiesPage); /** * @name IdentitiesStep * @description Displays linked accounts and available authentication methods. * LinkAccountsList component handles all authentication options including OAuth and Email/Password. */ function IdentitiesStep(props: { nextPath: string; showPasswordOption: boolean; showEmailOption: boolean; enableIdentityLinking: boolean; oAuthProviders: Provider[]; }) { return (
); } async function fetchData(props: IdentitiesPageProps) { const searchParams = await props.searchParams; const client = getSupabaseServerClient(); const auth = await requireUser(client); // If not authenticated, redirect to sign in if (!auth.data) { throw redirect(pathsConfig.auth.signIn); } // Get the next path from URL params (where to redirect after setup) const nextPath = searchParams.next || pathsConfig.app.home; // Available auth methods to add const showPasswordOption = authConfig.providers.password; // Show email option if password, magic link, or OTP is enabled const showEmailOption = authConfig.providers.password || authConfig.providers.magicLink || authConfig.providers.otp; const oAuthProviders = authConfig.providers.oAuth; const enableIdentityLinking = authConfig.enableIdentityLinking; return { nextPath, showPasswordOption, showEmailOption, oAuthProviders, enableIdentityLinking, }; }