initiation librodrome
This commit is contained in:
17
server/api/admin/auth/login.post.ts
Normal file
17
server/api/admin/auth/login.post.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
if (!config.adminPassword || !config.adminSecret) {
|
||||
throw createError({ statusCode: 503, statusMessage: 'Admin not configured' })
|
||||
}
|
||||
|
||||
const body = await readBody<{ password?: string }>(event)
|
||||
|
||||
if (!body?.password || body.password !== config.adminPassword) {
|
||||
throw createError({ statusCode: 401, statusMessage: 'Invalid password' })
|
||||
}
|
||||
|
||||
setAdminCookie(event, config.adminSecret)
|
||||
|
||||
return { ok: true }
|
||||
})
|
||||
Reference in New Issue
Block a user