mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-06-27 22:24:14 +00:00
fix: log out issue
This commit is contained in:
parent
d5c619567a
commit
333c97bfca
3 changed files with 20 additions and 2 deletions
18
backend/src/app/api/auth/logout/route.ts
Normal file
18
backend/src/app/api/auth/logout/route.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { auth } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const session = await auth();
|
||||
|
||||
if (session) {
|
||||
await prisma.session.deleteMany({
|
||||
where: { userId: Number(session?.user?.id) },
|
||||
});
|
||||
}
|
||||
|
||||
const response = NextResponse.redirect(process.env.NEXT_PUBLIC_FRONTEND_URL ?? "http://localhost:3000");
|
||||
response.cookies.delete("next-auth.session-token");
|
||||
response.cookies.delete("__Secure-next-auth.session-token");
|
||||
return response;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue