Introduce a new 'client' Next.js app scaffold: configuration files (next.config.ts, eslint.config.mjs, postcss, tsconfig), Prisma config and schema, app routes including NextAuth API and server actions, session/provider utilities, proxy, public assets, README and .gitignore. Also add IDE project files under .idea and a root README to initialize the repository structure for development.
29 lines
545 B
TypeScript
29 lines
545 B
TypeScript
//auth functions again teh database go here and get then gen imported to the route file to be used
|
|
"use server";
|
|
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
type UpsertGoogleUserInput = {
|
|
email: string;
|
|
name?: string | null;
|
|
};
|
|
|
|
export const createUserOnFirstGoogleLogin = async ({
|
|
email,
|
|
name,
|
|
}: UpsertGoogleUserInput) => {
|
|
const existingUser = await prisma.user.findUnique({
|
|
where: { email },
|
|
select: { id: true },
|
|
});
|
|
|
|
if (!existingUser) {
|
|
await prisma.user.create({
|
|
data: {
|
|
email,
|
|
name: name ?? null,
|
|
},
|
|
});
|
|
}
|
|
};
|