Decouple admin from public max-w-7xl via (site) route group.
Local Build and Deploy / deploy (push) Successful in 54s
Local Build and Deploy / deploy (push) Successful in 54s
Public chrome and width live only under (site). /admin and /client inherit the root layout alone, so housekeeping width is no longer tied to the public template. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
a1dc7ff0a7
commit
367f69a439
60 files changed
+29
-30
No files matched your search
@@ -0,0 +1,171 @@
|
||||
import Link from "next/link";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { isValidVerificationToken } from "@/actions/email-verify";
|
||||
import { DiscordVerifyForm } from "@/components/auth/discord-verify-form";
|
||||
import { ContentCard, EmptyState } from "@/components/public/ui";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
type Status = "verified" | "already" | "invalid" | "unavailable" | "discord";
|
||||
|
||||
export default async function VerifyPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{
|
||||
token?: string;
|
||||
email?: string;
|
||||
method?: string;
|
||||
linked?: string;
|
||||
}>;
|
||||
}) {
|
||||
const t = await getTranslations("pages.verify");
|
||||
const {
|
||||
token = "",
|
||||
email = "",
|
||||
method = "",
|
||||
linked = "",
|
||||
} = await searchParams;
|
||||
const normalisedEmail = email.trim().toLowerCase();
|
||||
|
||||
let status: Status = "invalid";
|
||||
let discordAlreadyLinked = false;
|
||||
|
||||
if (method === "discord" || linked === "1") {
|
||||
status = "discord";
|
||||
const session = await auth();
|
||||
if (session?.user?.id) {
|
||||
const userId = Number(session.user.id);
|
||||
try {
|
||||
const linkedRow = await prisma.socialAccounts.findFirst({
|
||||
where: { userId: BigInt(userId), provider: "discord" },
|
||||
select: { id: true },
|
||||
});
|
||||
discordAlreadyLinked = !!linkedRow;
|
||||
} catch {}
|
||||
}
|
||||
} else if (normalisedEmail && token) {
|
||||
const ok = await isValidVerificationToken(normalisedEmail, token);
|
||||
if (ok) {
|
||||
try {
|
||||
const user = await prisma.user.findFirst({
|
||||
where: { mail: normalisedEmail },
|
||||
select: { id: true, mailVerified: true },
|
||||
});
|
||||
if (!user) {
|
||||
status = "invalid";
|
||||
} else if (user.mailVerified === "1") {
|
||||
status = "already";
|
||||
} else {
|
||||
await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: { mailVerified: "1" },
|
||||
});
|
||||
status = "verified";
|
||||
}
|
||||
} catch {
|
||||
status = "unavailable";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<main style={{ maxWidth: 480, margin: "2rem auto" }}>
|
||||
{status === "verified" && (
|
||||
<ContentCard
|
||||
icon="✅"
|
||||
title={t("verifiedTitle")}
|
||||
subtitle={t("verifiedSubtitle")}
|
||||
>
|
||||
<p className="muted" style={{ marginTop: 0 }}>
|
||||
{t("verifiedBody")}
|
||||
</p>
|
||||
<Link href="/login" className="btn btn-primary">
|
||||
{t("goToLogin")}
|
||||
</Link>
|
||||
</ContentCard>
|
||||
)}
|
||||
|
||||
{status === "already" && (
|
||||
<ContentCard
|
||||
icon="✅"
|
||||
title={t("alreadyTitle")}
|
||||
subtitle={t("alreadySubtitle")}
|
||||
>
|
||||
<p className="muted" style={{ marginTop: 0 }}>
|
||||
{t("alreadyBody")}
|
||||
</p>
|
||||
<Link href="/login" className="btn btn-primary">
|
||||
{t("goToLogin")}
|
||||
</Link>
|
||||
</ContentCard>
|
||||
)}
|
||||
|
||||
{status === "unavailable" && (
|
||||
<ContentCard
|
||||
icon="⏳"
|
||||
title={t("unavailableTitle")}
|
||||
subtitle={t("unavailableSubtitle")}
|
||||
>
|
||||
<p className="muted" style={{ margin: 0 }}>
|
||||
{t("unavailableBody")}
|
||||
</p>
|
||||
</ContentCard>
|
||||
)}
|
||||
|
||||
{status === "invalid" && (
|
||||
<ContentCard
|
||||
icon="📧"
|
||||
title={t("invalidTitle")}
|
||||
subtitle={t("invalidSubtitle")}
|
||||
>
|
||||
<EmptyState icon="🔗">{t("invalidBody")}</EmptyState>
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<Link href="/login" className="btn btn-outline">
|
||||
{t("backToLogin")}
|
||||
</Link>
|
||||
</div>
|
||||
</ContentCard>
|
||||
)}
|
||||
|
||||
{status === "discord" && (
|
||||
<ContentCard
|
||||
icon="🎮"
|
||||
title="Verifieer via Discord"
|
||||
subtitle="Koppel je Discord account"
|
||||
>
|
||||
{linked === "1" && (
|
||||
<div
|
||||
className="rounded-md p-4 text-center mb-4"
|
||||
style={{ backgroundColor: "#14532d", color: "white" }}
|
||||
>
|
||||
<p className="text-lg font-bold mb-1">Gelinkt!</p>
|
||||
<p className="text-sm opacity-90">
|
||||
Je Discord account is gekoppeld. Je kunt nu verder.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{discordAlreadyLinked ? (
|
||||
<div
|
||||
className="rounded-md p-4 text-center"
|
||||
style={{ backgroundColor: "#14532d", color: "white" }}
|
||||
>
|
||||
<p className="text-lg font-bold mb-1">Al geverifieerd!</p>
|
||||
<p className="text-sm opacity-90">
|
||||
Je Discord account is al gekoppeld aan dit account.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<DiscordVerifyForm />
|
||||
)}
|
||||
<div style={{ textAlign: "center", marginTop: "1rem" }}>
|
||||
<Link href="/" className="btn btn-primary">
|
||||
Naar home
|
||||
</Link>
|
||||
</div>
|
||||
</ContentCard>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user