feat: initial brainstorming app — Nuxt 3 + SQLite + admin auth
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>
This commit is contained in:
20
app/composables/useAuth.ts
Normal file
20
app/composables/useAuth.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export function useAuth() {
|
||||
const admin = useState('admin', () => false)
|
||||
|
||||
async function check() {
|
||||
const data = await $fetch('/api/auth/me')
|
||||
admin.value = data.admin
|
||||
}
|
||||
|
||||
async function login(password: string) {
|
||||
await $fetch('/api/auth/login', { method: 'POST', body: { password } })
|
||||
admin.value = true
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await $fetch('/api/auth/logout', { method: 'POST' })
|
||||
admin.value = false
|
||||
}
|
||||
|
||||
return { admin, check, login, logout }
|
||||
}
|
||||
Reference in New Issue
Block a user