fix(admin): P0 integrity — permanent bans, ACL sidebar, rank guards
Deploy / release (push) Skipped
Deploy / deploy (push) Successful in 1m36s

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-07-22 19:01:59 +02:00
1 parent 11004626c7
commit 75cdfdebe4
14 files changed
+458 -68

No files matched your search

+18 -14
View File
@@ -1,6 +1,7 @@
import { getTranslations } from "next-intl/server";
import { ContentCard } from "@/components/public/ui";
import { auth } from "@/lib/auth";
import { activeBanWhere, unixNow } from "@/lib/bans";
import { prisma } from "@/lib/prisma";
export const dynamic = "force-dynamic";
@@ -12,15 +13,19 @@ export default async function BannedPage() {
const session = await auth();
let reason = "";
let expire = 0;
let hasBan = false;
if (session?.user?.id) {
try {
const now = Math.floor(Date.now() / 1000);
const ban = await prisma.ban.findFirst({
where: { userId: Number(session.user.id), banExpire: { gt: now } },
orderBy: { banExpire: "desc" },
where: {
userId: Number(session.user.id),
...activeBanWhere(unixNow()),
},
orderBy: { timestamp: "desc" },
select: { banReason: true, banExpire: true },
});
if (ban) {
hasBan = true;
reason = ban.banReason;
expire = ban.banExpire;
}
@@ -29,17 +34,16 @@ export default async function BannedPage() {
}
}
const expiryText =
expire === 0
? ""
: expire > FAR_FUTURE
? t("permanent")
: t("expires", {
date: new Date(expire * 1000)
.toISOString()
.slice(0, 16)
.replace("T", " "),
});
const expiryText = !hasBan
? ""
: expire === 0 || expire > FAR_FUTURE
? t("permanent")
: t("expires", {
date: new Date(expire * 1000)
.toISOString()
.slice(0, 16)
.replace("T", " "),
});
return (
<main style={{ maxWidth: 560, margin: "2rem auto" }}>