Add default admin user creation and fix modal overlay positioning
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user