import { OnboardingLayout } from "@/components/layouts/onboarding-layout"; import { Logo } from "@/components/shared/logo"; import { CardDescription, CardTitle } from "@/components/ui/card"; import { db } from "@/server/db"; import { auth } from "@/server/db/schema"; import { IS_CLOUD, updateAuthById } from "@dokploy/server"; import { isBefore } from "date-fns"; import { eq } from "drizzle-orm"; import type { GetServerSidePropsContext } from "next"; import Link from "next/link"; import type { ReactElement } from "react"; export default function Home() { return (
Dokploy Email Confirmed Congratulations, your email is confirmed.
Click here to login
); } Home.getLayout = (page: ReactElement) => { return {page}; }; export async function getServerSideProps(context: GetServerSidePropsContext) { if (!IS_CLOUD) { return { redirect: { permanent: true, destination: "/", }, }; } const { token } = context.query; if (typeof token !== "string") { return { redirect: { permanent: true, destination: "/", }, }; } const authR = await db.query.auth.findFirst({ where: eq(auth.confirmationToken, token), }); if ( !authR || authR?.confirmationToken === null || authR?.confirmationExpiresAt === null ) { return { redirect: { permanent: true, destination: "/", }, }; } const isExpired = isBefore(new Date(authR.confirmationExpiresAt), new Date()); if (isExpired) { return { redirect: { permanent: true, destination: "/", }, }; } await updateAuthById(authR.id, { confirmationToken: null, confirmationExpiresAt: null, }); return { props: { token: authR.confirmationToken, }, }; }