first commit
CI / Type-check & Build (push) Failing after 5m50s
CI / Build & Push image (push) Skipped

This commit is contained in:
ysj7705 committed 2026-08-12 15:01:43 +09:00
commit 69b647145f
58 files changed
+15796

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import { ADMIN_COOKIE, signAdminToken } from '../../utils/jwt'
export default defineEventHandler(async (event) => {
const body = await readBody<{ username?: string; password?: string }>(event)
const config = useRuntimeConfig()
if (!body?.username || !body?.password) {
throw createError({ statusCode: 400, statusMessage: 'Username and password required' })
}
if (body.username !== config.adminUsername || body.password !== config.adminPassword) {
throw createError({ statusCode: 401, statusMessage: 'Invalid credentials' })
}
const token = await signAdminToken(body.username)
setCookie(event, ADMIN_COOKIE, token, {
httpOnly: true,
sameSite: 'lax',
secure: process.env.NODE_ENV === 'production',
path: '/',
maxAge: 60 * 60 * 24 * 7,
})
return { ok: true, username: body.username }
})