43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
|
// The sign-up page of the Convex Better Auth adapter (AUTH_PROVIDER=convex-better-auth): a new
|
|
// account with an e-mail address and a password. An OIDC deployment has its identity provider's own
|
|
// registration, so this page is not found there.
|
|
|
|
import { loadAuthConfig } from "@conusai-kit/auth"
|
|
import { notFound, redirect } from "next/navigation"
|
|
import type { ReactElement } from "react"
|
|
import { safeReturnTo } from "../../../src/server/auth-errors"
|
|
import { betterAuthFormLabels, MIN_PASSWORD_LENGTH } from "../../../src/server/better-auth"
|
|
import { pageContext } from "../../../src/server/page"
|
|
import { BetterAuthForm } from "../../../src/ui/better-auth-form"
|
|
import { StateView } from "../../../src/ui/state-view"
|
|
|
|
export const dynamic = "force-dynamic"
|
|
|
|
export default async function SignUp({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ return_to?: string }>
|
|
}): Promise<ReactElement> {
|
|
if (loadAuthConfig().provider !== "convex-better-auth") notFound()
|
|
const { return_to: returnToParam } = await searchParams
|
|
const { i18n, signedIn } = await pageContext()
|
|
const returnTo = safeReturnTo(returnToParam)
|
|
if (signedIn) redirect(returnTo)
|
|
const next = returnTo === "/" ? "" : `?return_to=${encodeURIComponent(returnTo)}`
|
|
return (
|
|
<StateView title={i18n.message("signin.account.signUpTitle")}>
|
|
<p>{i18n.message("signin.account.signUpIntro")}</p>
|
|
<BetterAuthForm
|
|
mode="sign-up"
|
|
returnTo={returnTo}
|
|
minPasswordLength={MIN_PASSWORD_LENGTH}
|
|
labels={betterAuthFormLabels(i18n, "sign-up")}
|
|
/>
|
|
<p>
|
|
<a href={`/auth/sign-in${next}`}>{i18n.message("signin.account.toSignIn")}</a>
|
|
</p>
|
|
</StateView>
|
|
)
|
|
}
|