Add default admin user creation and fix modal overlay positioning

This commit is contained in:
Ryderjj89
2025-09-29 20:21:55 -04:00
parent eba89f987f
commit 89c75564cf
2 changed files with 48 additions and 1 deletions

View File

@@ -51,7 +51,16 @@ async function initializeDatabase(db: Database.Database) {
)
`)
// Note: Admin user creation is handled in auth.ts to avoid circular dependencies
// Create default admin user if it doesn't exist
const config = useRuntimeConfig()
const bcrypt = await import('bcrypt')
const saltRounds = 10
const passwordHash = await bcrypt.hash(config.adminPassword, saltRounds)
const existingAdmin = db.prepare('SELECT id FROM users WHERE username = ?').get('admin')
if (!existingAdmin) {
db.prepare('INSERT INTO users (username, password_hash) VALUES (?, ?)').run('admin', passwordHash)
}
}
export function closeDatabase() {