Nuxt 3 app with: - SQLite (better-sqlite3) for persistence - Anonymous idea submission and voting - Admin auth with session cookies - AI analysis via Gemini API - Nuxt UI components + Tailwind Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
18 lines
489 B
TypeScript
18 lines
489 B
TypeScript
import { checkPassword, createSession } from '../../utils/auth'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const { password } = await readBody(event)
|
|
if (!password || !checkPassword(password)) {
|
|
throw createError({ statusCode: 401, statusMessage: 'Invalid password' })
|
|
}
|
|
const token = createSession()
|
|
setCookie(event, 'session', token, {
|
|
httpOnly: true,
|
|
secure: true,
|
|
sameSite: 'strict',
|
|
maxAge: 86400,
|
|
path: '/',
|
|
})
|
|
return { ok: true }
|
|
})
|