Add create account functionality
This commit is contained in:
parent
598b9fd7d6
commit
8ef4636635
8 changed files with 145 additions and 12 deletions
|
@ -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);
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue