2025-06-30 18:58:24 +02:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: © 2025 Hornwitser <code@hornwitser.no>
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
*/
|
2025-06-23 00:17:22 +02:00
|
|
|
import { readUsers } from "~/server/database";
|
2025-03-07 12:41:57 +01:00
|
|
|
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
|
|
const { name } = await readBody(event);
|
|
|
|
|
|
|
|
if (!name) {
|
|
|
|
return new Response(undefined, { status: 400 })
|
|
|
|
}
|
|
|
|
|
2025-06-23 00:17:22 +02:00
|
|
|
const accounts = await readUsers();
|
2025-03-07 12:41:57 +01:00
|
|
|
const account = accounts.find(a => a.name === name);
|
|
|
|
|
|
|
|
if (!account) {
|
|
|
|
return new Response(undefined, { status: 403 })
|
|
|
|
}
|
|
|
|
|
2025-06-23 00:17:22 +02:00
|
|
|
await setServerSession(event, account);
|
2025-03-07 12:41:57 +01:00
|
|
|
})
|