From 3fadb6d86da678bfe9c88c8dd393f574c5e9bd55 Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Thu, 15 Jan 2026 17:05:23 +0100 Subject: [PATCH] fix: fix error with automatic theme selection --- backend/database.go | 11 +++++++++-- frontend/src/App.svelte | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/database.go b/backend/database.go index 3f06ab6..0569420 100644 --- a/backend/database.go +++ b/backend/database.go @@ -4,6 +4,7 @@ import ( "database/sql" "fmt" "log" + "os" "sort" "strconv" "strings" @@ -41,8 +42,14 @@ func ensureAdminExists(db *sql.DB) { var count int db.QueryRow("SELECT COUNT(*) FROM users").Scan(&count) if count == 0 { - log.Println("Keine Benutzer gefunden. Erstelle Standard-Admin...") - pw, _ := bcrypt.GenerateFromPassword([]byte("admin123"), bcrypt.DefaultCost) + var pw []byte + if os.Getenv("INITIAL_ADMIN_PASSWORD") == "" { + log.Println("Keine Benutzer gefunden. Erstelle Standard-Admin...") + pw, _ = bcrypt.GenerateFromPassword([]byte("admin123"), bcrypt.DefaultCost) + } else { + initialPassword := os.Getenv("INITIAL_ADMIN_PASSWORD") + pw, _ = bcrypt.GenerateFromPassword([]byte(initialPassword), bcrypt.DefaultCost) + } _, err := db.Exec("INSERT INTO users (username, password, is_admin, yearly_hours) VALUES (?, ?, ?, ?)", "admin", string(pw), true, 0) if err != nil { diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 3fa1604..38f9a5e 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -15,7 +15,7 @@ const applyTheme = (e) => { const isDark = e.matches; - const theme = isDark ? 'night' : 'winter'; + const theme = isDark ? 'dark' : 'light'; document.documentElement.setAttribute('data-theme', theme); };