Files
towercontrol/src/middleware.ts
Julien Froidefond 17b86b6087 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.
2025-09-30 21:49:52 +02:00

34 lines
903 B
TypeScript

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)$).*)',
],
}