fixes create to now check for author before creating game system
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user