Add user authentication and role management
This commit is contained in:
17
app/api/auth/logout/route.ts
Normal file
17
app/api/auth/logout/route.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import {
|
||||
clearSessionCookie,
|
||||
deleteSession,
|
||||
sessionCookieFromHeader,
|
||||
} from "../../../../lib/user-auth";
|
||||
|
||||
export const runtime = "edge";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const token = sessionCookieFromHeader(request.headers.get("cookie"));
|
||||
await deleteSession(token);
|
||||
const secure = new URL(request.url).protocol === "https:";
|
||||
return Response.json(
|
||||
{ loggedOut: true },
|
||||
{ headers: { "Set-Cookie": clearSessionCookie(secure) } },
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user