From 44d7f95d4ca491392b712306d4f6b306605a0fcc Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 22 Feb 2026 14:23:11 +0100 Subject: [PATCH] feat: implement user authentication and route protection using NextAuth middleware and server actions. --- src/features/auth/api/login-action.ts | 2 +- src/middleware.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/features/auth/api/login-action.ts b/src/features/auth/api/login-action.ts index 9b514f9..df29b2f 100644 --- a/src/features/auth/api/login-action.ts +++ b/src/features/auth/api/login-action.ts @@ -11,7 +11,7 @@ export async function loginAction(prevState: string | undefined, formData: FormD await signIn("credentials", { username: formData.get("username"), password: formData.get("password"), - redirectTo: "/dashboard" + redirectTo: "/grid" }); } catch (error) { if (error instanceof AuthError) { diff --git a/src/middleware.ts b/src/middleware.ts index b637b75..56e8070 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -21,7 +21,7 @@ export default auth((req) => { // 3. Rediriger vers le dashboard si déjà connecté et sur /login if (isLoggedIn && isPublicRoute) { - return NextResponse.redirect(new URL("/dashboard", nextUrl)); + return NextResponse.redirect(new URL("/grid", nextUrl)); } // 4. Protection par rôle (Admin seulement pour les paramètres) @@ -29,7 +29,7 @@ export default auth((req) => { const userRole = (req.auth?.user as any)?.role; if (isAdminRoute && userRole !== "admin") { - return NextResponse.redirect(new URL("/dashboard", nextUrl)); + return NextResponse.redirect(new URL("/grid", nextUrl)); } return NextResponse.next();