fix: check if user is logged in before checking for punishments
This commit is contained in:
parent
f8838caa55
commit
62f33440f3
1 changed files with 9 additions and 7 deletions
|
|
@ -40,13 +40,15 @@ export default async function Page({ searchParams }: Props) {
|
|||
if (session?.user && !session.user.username) {
|
||||
redirect("/create-username");
|
||||
}
|
||||
const activePunishment = await prisma.punishment.findFirst({
|
||||
where: {
|
||||
userId: Number(session?.user.id),
|
||||
returned: false,
|
||||
},
|
||||
});
|
||||
if (activePunishment) redirect("/off-the-island");
|
||||
if (session?.user) {
|
||||
const activePunishment = await prisma.punishment.findFirst({
|
||||
where: {
|
||||
userId: Number(session?.user.id),
|
||||
returned: false,
|
||||
},
|
||||
});
|
||||
if (activePunishment) redirect("/off-the-island");
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
|||
Loading…
Reference in a new issue