mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-16 09:56:36 +00:00
36 lines
901 B
TypeScript
36 lines
901 B
TypeScript
import VerifyEmailForm from "@app/app/auth/verify-email/VerifyEmailForm";
|
|
import { verifySession } from "@app/lib/auth/verifySession";
|
|
import { redirect } from "next/navigation";
|
|
import { cache } from "react";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export default async function Page(props: {
|
|
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
|
}) {
|
|
if (process.env.PUBLIC_FLAGS_EMAIL_VERIFICATION_REQUIRED !== "true") {
|
|
redirect("/");
|
|
}
|
|
|
|
const searchParams = await props.searchParams;
|
|
const getUser = cache(verifySession);
|
|
const user = await getUser();
|
|
|
|
if (!user) {
|
|
redirect("/");
|
|
}
|
|
|
|
if (user.emailVerified) {
|
|
redirect("/");
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<VerifyEmailForm
|
|
email={user.email}
|
|
redirect={searchParams.redirect as string}
|
|
/>
|
|
</>
|
|
);
|
|
}
|