owltide/server/api/auth/login.post.ts
Hornwitser 251e83f640
All checks were successful
/ build (push) Successful in 1m12s
/ deploy (push) Successful in 16s
Rename AcountSession to ServerSession
Start the work of clearly distingushing client side types, server side
types and types shared over the API by renaming "AccountSession" and
"Session" names used on the server to "ServerSession".
2025-06-09 16:51:05 +02:00

18 lines
427 B
TypeScript

import { readAccounts } from "~/server/database";
export default defineEventHandler(async (event) => {
const { name } = await readBody(event);
if (!name) {
return new Response(undefined, { status: 400 })
}
const accounts = await readAccounts();
const account = accounts.find(a => a.name === name);
if (!account) {
return new Response(undefined, { status: 403 })
}
await setServerSession(event, account.id);
})