Add create account functionality

This commit is contained in:
Hornwitser 2025-03-07 23:53:57 +01:00
parent 598b9fd7d6
commit 8ef4636635
8 changed files with 145 additions and 12 deletions

View file

@ -1,3 +1,19 @@
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);
})