feat: logout

This commit is contained in:
Ivan Rezchikov
2026-06-18 22:52:49 +03:00
parent 6c89f21039
commit dfc3dd2065
13 changed files with 172 additions and 128 deletions
+26
View File
@@ -0,0 +1,26 @@
import { prisma } from "@/lib/prisma";
import { v4 as uuidv4 } from "uuid";
export async function findUserByKotosoftId(kotosoftId: string) {
return prisma.user.findUnique({ where: { kotosoftId } });
}
export async function findUserById(id: string) {
return prisma.user.findUnique({ where: { id } });
}
export async function findOrCreateUser(data: {
kotosoftId: string;
email: string;
firstName: string;
secondName: string;
sex: string;
birthDate: string;
}) {
const existing = await findUserByKotosoftId(data.kotosoftId);
if (existing) return existing;
return prisma.user.create({
data: { id: uuidv4(), ...data },
});
}