owltide/server/api/auth/session.delete.ts
Hornwitser 3be7f8be05 Refactor user storage and update
Rename accounts to users to be consistent with the new naming scheme
where account only referes to the logged in user of the session and
implement live updates of users via a user store which listens for
updates from the event stream.
2025-06-23 00:28:58 +02:00

18 lines
423 B
TypeScript

import { cancelSessionStreams } from "~/server/streams";
export default defineEventHandler(async (event) => {
const session = await getServerSession(event);
if (session) {
if (session.account.type === "anonymous") {
throw createError({
status: 409,
message: "Cannot log out of an anonymous account",
});
}
}
if (session) {
cancelSessionStreams(session.id);
}
await clearServerSession(event);
})