feat: add authentication support and user model

- Updated `env.example` to include NextAuth configuration for authentication.
- Added `next-auth` dependency to manage user sessions.
- Introduced `User` model in Prisma schema with fields for user details and password hashing.
- Integrated `AuthProvider` in layout for session management across the app.
- Enhanced `Header` component with `AuthButton` for user authentication controls.
This commit is contained in:
Julien Froidefond
2025-09-30 21:49:52 +02:00
parent 43c141d3cd
commit 17b86b6087
20 changed files with 1418 additions and 13 deletions

33
src/middleware.ts Normal file
View File

@@ -0,0 +1,33 @@
import { withAuth } from "next-auth/middleware"
export default withAuth(
function middleware() {
// Le middleware s'exécute seulement si l'utilisateur est authentifié
// grâce à withAuth
},
{
callbacks: {
authorized: ({ token }) => {
// Vérifier si l'utilisateur a un token valide
return !!token
},
},
}
)
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api/auth (NextAuth routes)
* - login (login page)
* - register (registration page)
* - profile (profile page)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
* - public files (images, etc.)
*/
'/((?!api/auth|login|register|profile|_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)',
],
}