Remove Discord and Google OAuth verification from CMS
- Remove Discord + Google OAuth providers from NextAuth config - Remove social login buttons (Discord/Google) from login form - Delete link-discord.ts action and discord-verify-form.tsx component - Simplify verify page to email-only verification flow - Remove connections settings page and its link from settings - Clean env.ts, .env, .env.example of Discord/Google client vars - Remove discordUrl social icon from register, login, and homepage - Clean translation files: remove continueWithDiscord, continueWithGoogle, connections keys
This commit is contained in:
1 parent
f7f6e09174
commit
7f8d083763
36 files changed
+34
-994
No files matched your search
@@ -73,11 +73,7 @@ export default async function LoginPage() {
|
||||
<div className="flex items-center gap-1.5 rounded-lg px-2 py-1" style={{
|
||||
background: "color-mix(in srgb, var(--color-text-muted) 4%, transparent)",
|
||||
}}>
|
||||
{discordUrl && (
|
||||
<Link href={discordUrl} target="_blank" rel="noopener noreferrer" className="p-1.5 rounded-lg transition-all duration-200 hover:scale-110 hover:brightness-125" style={{ background: "color-mix(in srgb, #5865F2 12%, transparent)" }}>
|
||||
<Image src="/assets/images/icons/discord.png" alt="Discord" width={18} height={18} unoptimized />
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<LanguageSwitcher />
|
||||
<div className="w-px h-5" style={{ background: "color-mix(in srgb, var(--color-text-muted) 12%, transparent)" }} />
|
||||
<Clock />
|
||||
|
||||
@@ -99,11 +99,7 @@ export default async function Home() {
|
||||
<div className="flex items-center gap-1.5 rounded-lg px-2 py-1" style={{
|
||||
background: "color-mix(in srgb, var(--color-text-muted) 4%, transparent)",
|
||||
}}>
|
||||
{discordUrl && (
|
||||
<Link href={discordUrl} target="_blank" rel="noopener noreferrer" className="p-1.5 rounded-lg transition-all duration-200 hover:scale-110 hover:brightness-125" style={{ background: "color-mix(in srgb, #5865F2 12%, transparent)" }}>
|
||||
<Image src="/assets/images/icons/discord.png" alt="Discord" width={18} height={18} unoptimized />
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<LanguageSwitcher />
|
||||
<div className="w-px h-5" style={{ background: "color-mix(in srgb, var(--color-text-muted) 12%, transparent)" }} />
|
||||
<Clock />
|
||||
|
||||
@@ -73,11 +73,7 @@ export default async function RegisterPage() {
|
||||
<div className="flex items-center gap-1.5 rounded-lg px-2 py-1" style={{
|
||||
background: "color-mix(in srgb, var(--color-text-muted) 4%, transparent)",
|
||||
}}>
|
||||
{discordUrl && (
|
||||
<Link href={discordUrl} target="_blank" rel="noopener noreferrer" className="p-1.5 rounded-lg transition-all duration-200 hover:scale-110 hover:brightness-125" style={{ background: "color-mix(in srgb, #5865F2 12%, transparent)" }}>
|
||||
<Image src="/assets/images/icons/discord.png" alt="Discord" width={18} height={18} unoptimized />
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<LanguageSwitcher />
|
||||
<div className="w-px h-5" style={{ background: "color-mix(in srgb, var(--color-text-muted) 12%, transparent)" }} />
|
||||
<Clock />
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { ContentCard } from "@/components/public/ui";
|
||||
import { env } from "@/env";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// Social providers we can link. `available` reflects whether the OAuth app
|
||||
// credentials are configured (mirrors src/lib/auth.ts, which only registers a
|
||||
// provider when both its id + secret env vars are set). When unavailable the
|
||||
// connect button is disabled so we don't bounce the user to a 404 sign-in URL.
|
||||
const PROVIDERS = [
|
||||
{
|
||||
key: "discord",
|
||||
label: "Discord",
|
||||
icon: "🎮",
|
||||
available: Boolean(env.DISCORD_CLIENT_ID && env.DISCORD_CLIENT_SECRET),
|
||||
},
|
||||
{
|
||||
key: "google",
|
||||
label: "Google",
|
||||
icon: "🔵",
|
||||
available: Boolean(env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET),
|
||||
},
|
||||
] as const;
|
||||
|
||||
export default async function ConnectionsPage() {
|
||||
const t = await getTranslations("pages.connections");
|
||||
const session = await auth();
|
||||
if (!session?.user?.id) redirect("/login");
|
||||
|
||||
const id = Number(session.user.id);
|
||||
|
||||
// social_accounts is a CMS-only table that may not exist in every install
|
||||
// (it has no bundled migration). Fall back to "nothing linked" on any error so
|
||||
// the page still renders the generic connect buttons.
|
||||
let linked: Set<string> = new Set();
|
||||
let lookupFailed = false;
|
||||
try {
|
||||
const rows = await prisma.socialAccounts.findMany({
|
||||
where: { userId: BigInt(id) },
|
||||
select: { provider: true },
|
||||
});
|
||||
linked = new Set(rows.map((r) => r.provider.toLowerCase()));
|
||||
} catch {
|
||||
lookupFailed = true;
|
||||
}
|
||||
|
||||
// After connecting/erroring, NextAuth bounces back here so we land on a known page.
|
||||
const callbackUrl = "/settings/connections";
|
||||
|
||||
return (
|
||||
<main
|
||||
style={{
|
||||
display: "grid",
|
||||
gap: "1.5rem",
|
||||
maxWidth: 620,
|
||||
margin: "0 auto",
|
||||
}}
|
||||
>
|
||||
<p className="muted" style={{ margin: 0 }}>
|
||||
<Link href="/settings">{t("backToSettings")}</Link>
|
||||
</p>
|
||||
|
||||
<ContentCard icon="🔗" title={t("title")} subtitle={t("subtitle")}>
|
||||
<p className="muted" style={{ marginTop: 0 }}>
|
||||
{t("matchByEmail")} <strong>{session.user.name}</strong>.
|
||||
</p>
|
||||
|
||||
{lookupFailed ? (
|
||||
<p className="muted" style={{ marginBottom: 0 }}>
|
||||
{t("lookupFailed")}
|
||||
</p>
|
||||
) : null}
|
||||
</ContentCard>
|
||||
|
||||
<div className="card-grid sm-2">
|
||||
{PROVIDERS.map((p) => {
|
||||
const isLinked = linked.has(p.key);
|
||||
return (
|
||||
<ContentCard
|
||||
key={p.key}
|
||||
icon={p.icon}
|
||||
title={p.label}
|
||||
subtitle={
|
||||
!p.available
|
||||
? t("statusUnavailable")
|
||||
: isLinked
|
||||
? t("statusConnected")
|
||||
: t("statusNotConnected")
|
||||
}
|
||||
>
|
||||
{isLinked ? (
|
||||
<span
|
||||
className="btn btn-outline"
|
||||
style={{ cursor: "default", pointerEvents: "none" }}
|
||||
aria-disabled="true"
|
||||
>
|
||||
{t("connected")}
|
||||
</span>
|
||||
) : p.available ? (
|
||||
// Plain link into NextAuth's built-in sign-in handler. Re-using
|
||||
// the same OAuth flow as /login binds the provider to the
|
||||
// matching hotel account (see auth.ts signIn callback).
|
||||
<a
|
||||
className="btn btn-primary"
|
||||
href={`/api/auth/signin/${p.key}?callbackUrl=${encodeURIComponent(callbackUrl)}`}
|
||||
>
|
||||
{t("connectProvider", { provider: p.label })}
|
||||
</a>
|
||||
) : (
|
||||
<span
|
||||
className="btn"
|
||||
style={{
|
||||
cursor: "not-allowed",
|
||||
opacity: 0.55,
|
||||
pointerEvents: "none",
|
||||
}}
|
||||
aria-disabled="true"
|
||||
>
|
||||
{t("unavailable")}
|
||||
</span>
|
||||
)}
|
||||
</ContentCard>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<p className="muted" style={{ margin: 0 }}>
|
||||
{t("footerNote")}
|
||||
</p>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -127,19 +127,7 @@ export default async function SettingsPage() {
|
||||
</Link>
|
||||
</ContentCard>
|
||||
|
||||
<ContentCard
|
||||
icon="🔗"
|
||||
title={t("connectionsTitle")}
|
||||
subtitle={t("connectionsSubtitle")}
|
||||
>
|
||||
<p className="muted" style={{ marginTop: 0 }}>
|
||||
{t("connectionsDescription")}
|
||||
</p>
|
||||
<Link href="/settings/connections" className="btn btn-outline">
|
||||
{t("manageConnections")}
|
||||
</Link>
|
||||
</ContentCard>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
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";
|
||||
type Status = "verified" | "already" | "invalid" | "unavailable";
|
||||
|
||||
export default async function VerifyPage({
|
||||
searchParams,
|
||||
@@ -16,36 +14,15 @@ export default async function VerifyPage({
|
||||
searchParams: Promise<{
|
||||
token?: string;
|
||||
email?: string;
|
||||
method?: string;
|
||||
linked?: string;
|
||||
}>;
|
||||
}) {
|
||||
const t = await getTranslations("pages.verify");
|
||||
const {
|
||||
token = "",
|
||||
email = "",
|
||||
method = "",
|
||||
linked = "",
|
||||
} = await searchParams;
|
||||
const { token = "", email = "" } = 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) {
|
||||
if (normalisedEmail && token) {
|
||||
const ok = await isValidVerificationToken(normalisedEmail, token);
|
||||
if (ok) {
|
||||
try {
|
||||
@@ -128,44 +105,6 @@ export default async function VerifyPage({
|
||||
</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