fix: check if user is logged in before checking for punishments

This commit is contained in:
trafficlunar 2025-06-02 23:36:56 +01:00 committed by GitHub
parent f8838caa55
commit 62f33440f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -40,13 +40,15 @@ export default async function Page({ searchParams }: Props) {
if (session?.user && !session.user.username) { if (session?.user && !session.user.username) {
redirect("/create-username"); redirect("/create-username");
} }
const activePunishment = await prisma.punishment.findFirst({ if (session?.user) {
where: { const activePunishment = await prisma.punishment.findFirst({
userId: Number(session?.user.id), where: {
returned: false, userId: Number(session?.user.id),
}, returned: false,
}); },
if (activePunishment) redirect("/off-the-island"); });
if (activePunishment) redirect("/off-the-island");
}
return ( return (
<> <>