refactor: review cookie code for auth
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { AuthService } from "@/services";
|
||||
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
@@ -8,14 +10,8 @@ export async function POST() {
|
||||
{ status: 200 }
|
||||
);
|
||||
|
||||
// Supprimer le cookie de session
|
||||
response.cookies.set("session_token", "", {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
sameSite: "lax",
|
||||
maxAge: 0, // Expire immédiatement
|
||||
path: "/",
|
||||
});
|
||||
// Supprimer la session et le cookie
|
||||
AuthService.removeSession(response);
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user