PrismaP
Prisma16mo ago
4 replies
Panic

Kinde + Prisma ORM

Hey all having an issue when implementing Kinde on a personal project.


Object literal may only specify known properties, and 'kindeId' does not exist in type 'UserWhereUniqueInput'.ts(2353)

import {PrismaClient} from "@prisma/client";
import {getKindeServerSession} from "@kinde-oss/kinde-auth-nextjs/server";
import {NextResponse} from "next/server";

const prisma = new PrismaClient();

export async function GET() {
const {getUser} = getKindeServerSession();
const user = await getUser();

if (!user user == null !user.id)
throw new Error("something went wrong with authentication" + user);

let dbUser = await prisma.user.findUnique({
where: {kindeId: user.id}
});

if (!dbUser) {
dbUser = await prisma.user.create({
data: {
kindeId: user.id,
firstName: user.given_name ?? "",
lastName: user.family_name ?? "",
email: user.email ?? "" // Using nullish coalescing operator to provide a default empty string value
}
});
}

return NextResponse.redirect("http://localhost:3000/dashboard");
}

I confirmed that the KindeId is unique in my prisma model. Would love a second pair of eyes.
Was this page helpful?