mirror of
https://git.moonleay.net/Websites/liljudd-website.git
synced 2025-07-24 17:55:07 +02:00
Unfinished
This commit is contained in:
parent
18c6535d1c
commit
6b388729d9
25 changed files with 1598 additions and 2352 deletions
19
src/routes/api/auth/logout.ts
Normal file
19
src/routes/api/auth/logout.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { APIEvent } from "@solidjs/start/server/types";
|
||||
import { appendHeader } from "vinxi/http";
|
||||
import { lucia } from "~/lib/auth";
|
||||
|
||||
export const GET = async (event: APIEvent) => {
|
||||
if (!event.nativeEvent.context.session) {
|
||||
return new Error("Unauthorized");
|
||||
}
|
||||
await lucia.invalidateSession(event.nativeEvent.context.session.id);
|
||||
appendHeader(
|
||||
event,
|
||||
"Set-Cookie",
|
||||
lucia.createBlankSessionCookie().serialize(),
|
||||
);
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: { Location: "/" },
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue