feat: implement auth system, passkeys, and user management

Add PostgreSQL and Redis integration for users and sessions
Implement password and WebAuthn passkey login flows
Add Docker stack, super-admin seeding, and protected routes
This commit is contained in:
2026-04-12 20:16:43 +08:00
parent a649c509c2
commit 377a9617be
45 changed files with 3620 additions and 104 deletions

12
app/middleware/auth.ts Normal file
View File

@@ -0,0 +1,12 @@
export default defineNuxtRouteMiddleware(async (to) => {
const auth = useAuth()
await auth.fetchSession()
if (!auth.user.value) {
return navigateTo('/login')
}
if (to.path !== '/security' && auth.needsOnboarding.value) {
return navigateTo('/security')
}
})

14
app/middleware/guest.ts Normal file
View File

@@ -0,0 +1,14 @@
export default defineNuxtRouteMiddleware(async () => {
const auth = useAuth()
await auth.fetchSession()
if (!auth.user.value) {
return
}
if (auth.needsOnboarding.value) {
return navigateTo('/security')
}
return navigateTo(auth.isSuperAdmin.value ? '/management/users' : '/security')
})

View File

@@ -0,0 +1,16 @@
export default defineNuxtRouteMiddleware(async () => {
const auth = useAuth()
await auth.fetchSession()
if (!auth.user.value) {
return navigateTo('/login')
}
if (auth.needsOnboarding.value) {
return navigateTo('/security')
}
if (!auth.isSuperAdmin.value) {
return navigateTo('/security')
}
})