portfolio/server/api/auth/verify-password.post.ts

14 lines
300 B
TypeScript

export default defineEventHandler(async (event) => {
checkRateLimit(event)
const config = useRuntimeConfig()
const body = await readBody(event)
if (body.password === config.adminPassword) {
const token = createToken()
return { valid: true, token }
}
return { valid: false }
})