fixes create to now check for author before creating game system

This commit is contained in:
2024-08-20 07:51:20 -06:00
parent 729aba68ce
commit 5f2243b49a
2 changed files with 26 additions and 13 deletions

View File

@@ -1,11 +1,23 @@
"use server";
import { auth } from "@/auth";
import { prisma } from "@/prisma/prismaClient";
export const createGameSystem = async (name: string) => {
const session = await auth();
if (!session?.user?.id) return null;
const user = await prisma.user.findFirst({
where: { id: session.user.id },
select: { emailVerified: true },
});
if (!user?.emailVerified) return null;
const { id } = await prisma.gameSystem.create({
data: {
name,
authorId: session.user.id,
},
select: {
id: true,