fix: fix error with automatic theme selection
This commit is contained in:
parent
62496ffab6
commit
3fadb6d86d
2 changed files with 10 additions and 3 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue