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,6 +40,7 @@ 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");
} }
if (session?.user) {
const activePunishment = await prisma.punishment.findFirst({ const activePunishment = await prisma.punishment.findFirst({
where: { where: {
userId: Number(session?.user.id), userId: Number(session?.user.id),
@ -47,6 +48,7 @@ export default async function Page({ searchParams }: Props) {
}, },
}); });
if (activePunishment) redirect("/off-the-island"); if (activePunishment) redirect("/off-the-island");
}
return ( return (
<> <>