passkeys.tsx93 lines · main
| 1 | import { IS_PLATFORM, useFeatureFlags, useFlag } from 'common' |
| 2 | import { PageContainer } from 'ui-patterns/PageContainer' |
| 3 | import { |
| 4 | PageHeader, |
| 5 | PageHeaderDescription, |
| 6 | PageHeaderMeta, |
| 7 | PageHeaderSummary, |
| 8 | PageHeaderTitle, |
| 9 | } from 'ui-patterns/PageHeader' |
| 10 | import { PageSection, PageSectionContent } from 'ui-patterns/PageSection' |
| 11 | import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader' |
| 12 | |
| 13 | import { PasskeysSettingsForm } from '@/components/interfaces/Auth/Passkeys/PasskeysSettingsForm' |
| 14 | import AuthLayout from '@/components/layouts/AuthLayout/AuthLayout' |
| 15 | import DefaultLayout from '@/components/layouts/DefaultLayout' |
| 16 | import type { NextPageWithLayout } from '@/types' |
| 17 | |
| 18 | const PasskeysPage: NextPageWithLayout = () => { |
| 19 | const { hasLoaded: flagsLoaded } = useFeatureFlags() |
| 20 | const isPasskeyAuthEnabled = useFlag('enablePasskeyAuth') |
| 21 | |
| 22 | const isResolvingPasskeyFlag = IS_PLATFORM && !flagsLoaded |
| 23 | |
| 24 | if (isResolvingPasskeyFlag) { |
| 25 | return ( |
| 26 | <> |
| 27 | <PageHeader size="default"> |
| 28 | <PageHeaderMeta> |
| 29 | <HeaderSummary /> |
| 30 | </PageHeaderMeta> |
| 31 | </PageHeader> |
| 32 | <PageContainer size="default"> |
| 33 | <PageSection> |
| 34 | <PageSectionContent> |
| 35 | <GenericSkeletonLoader /> |
| 36 | </PageSectionContent> |
| 37 | </PageSection> |
| 38 | </PageContainer> |
| 39 | </> |
| 40 | ) |
| 41 | } |
| 42 | |
| 43 | if (!isPasskeyAuthEnabled) { |
| 44 | return ( |
| 45 | <PageContainer size="default"> |
| 46 | <PageSection> |
| 47 | <PageSectionContent> |
| 48 | <p className="text-sm text-foreground-light"> |
| 49 | Passkey authentication is not available for this project. |
| 50 | </p> |
| 51 | </PageSectionContent> |
| 52 | </PageSection> |
| 53 | </PageContainer> |
| 54 | ) |
| 55 | } |
| 56 | |
| 57 | return ( |
| 58 | <> |
| 59 | <PageHeader size="default"> |
| 60 | <PageHeaderMeta> |
| 61 | <HeaderSummary /> |
| 62 | </PageHeaderMeta> |
| 63 | </PageHeader> |
| 64 | <PageContainer size="default"> |
| 65 | <PageSection> |
| 66 | <PageSectionContent> |
| 67 | <PasskeysSettingsForm /> |
| 68 | </PageSectionContent> |
| 69 | </PageSection> |
| 70 | </PageContainer> |
| 71 | </> |
| 72 | ) |
| 73 | } |
| 74 | |
| 75 | const HeaderSummary = () => { |
| 76 | return ( |
| 77 | <PageHeaderSummary> |
| 78 | <PageHeaderTitle>Passkeys</PageHeaderTitle> |
| 79 | <PageHeaderDescription> |
| 80 | Configure WebAuthn passkeys so users can sign in with biometrics, security keys, or platform |
| 81 | authenticators |
| 82 | </PageHeaderDescription> |
| 83 | </PageHeaderSummary> |
| 84 | ) |
| 85 | } |
| 86 | |
| 87 | PasskeysPage.getLayout = (page) => ( |
| 88 | <DefaultLayout> |
| 89 | <AuthLayout title="Passkeys">{page}</AuthLayout> |
| 90 | </DefaultLayout> |
| 91 | ) |
| 92 | |
| 93 | export default PasskeysPage |