Initial commit - project setup

This commit is contained in:
Alexandru Eduard Farcas
2025-04-27 17:13:38 +03:00
parent 5be661f41a
commit d8da8c839f
22 changed files with 1775 additions and 144 deletions
+40
View File
@@ -0,0 +1,40 @@
import NextAuth, { SessionStrategy } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import { db } from "@/lib/db"; // Ensure this is the correct path to your Prisma client
if (!db) {
throw new Error("Prisma client is not initialized. Check your database configuration.");
}
export const authOptions = {
adapter: PrismaAdapter(db),
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}),
],
secret: process.env.NEXTAUTH_SECRET,
session: {
strategy: "database" as SessionStrategy,
},
callbacks: {
async signIn({ user, account, profile }: { user: any; account: any; profile?: any }) {
if (!user || !account || !profile) {
console.error("Sign-in failed: Missing user, account, or profile data.");
return false;
}
return true;
},
async session({ session, user }: { session: any; user: { id: string } }) {
session.user.id = user.id; // Attach user ID to the session
return session;
},
},
debug: true, // Enable debug mode for detailed error messages
};
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };