19 lines
492 B
TypeScript
19 lines
492 B
TypeScript
import { readAccounts } from "~/server/database";
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const session = await getAccountSession(event);
|
|
if (session) {
|
|
const accounts = await readAccounts();
|
|
const account = accounts.find(
|
|
account => account.id === session.accountId
|
|
);
|
|
if (account && account.type === "anonymous") {
|
|
throw createError({
|
|
status: 409,
|
|
message: "Cannot log out of an anonymous account",
|
|
});
|
|
}
|
|
}
|
|
|
|
await clearAccountSession(event);
|
|
})
|