feat: integrate authentication and password management features, including bcrypt for hashing and NextAuth for session handling

This commit is contained in:
Julien Froidefond
2025-11-30 08:04:06 +01:00
parent 7cb1d5f433
commit d663fbcbd0
30 changed files with 3287 additions and 4164 deletions

21
lib/auth-utils.ts Normal file
View File

@@ -0,0 +1,21 @@
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
import { NextResponse } from "next/server";
/**
* Verify that the user is authenticated
* Returns null if authenticated, or a NextResponse with 401 if not
*/
export async function requireAuth(): Promise<NextResponse | null> {
const session = await getServerSession(authOptions);
if (!session) {
return NextResponse.json(
{ error: "Non authentifié" },
{ status: 401 }
);
}
return null;
}