fix(admin): P0 integrity — permanent bans, ACL sidebar, rank guards
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
11004626c7
commit
75cdfdebe4
14 files changed
+458
-68
No files matched your search
@@ -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" }}>
|
||||
|
||||
Reference in new issue
Block a user