Refactor event handling and user management: Replace direct database calls with service layer methods for events, user profiles, and preferences, enhancing code organization and maintainability. Update API routes to utilize new services for event registration, feedback, and user statistics, ensuring a consistent approach across the application.

This commit is contained in:
Julien Froidefond
2025-12-12 16:19:13 +01:00
parent fd095246a3
commit 494ac3f503
34 changed files with 1795 additions and 1096 deletions

View File

@@ -1,7 +1,6 @@
import NextAuth from "next-auth";
import Credentials from "next-auth/providers/credentials";
import { prisma } from "./prisma";
import bcrypt from "bcryptjs";
import { userService } from "@/services/users/user.service";
import type { Role } from "@/prisma/generated/prisma/client";
export const { handlers, signIn, signOut, auth } = NextAuth({
@@ -17,20 +16,12 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
return null;
}
const user = await prisma.user.findUnique({
where: { email: credentials.email as string },
});
if (!user) {
return null;
}
const isPasswordValid = await bcrypt.compare(
credentials.password as string,
user.password
const user = await userService.verifyCredentials(
credentials.email as string,
credentials.password as string
);
if (!isPasswordValid) {
if (!user) {
return null;
}