fix: print initial admin credentials to console on first bootstrap

This commit is contained in:
line-6000
2026-05-11 12:20:36 +08:00
parent 2d546e3478
commit a8a3b8697f
+5 -3
View File
@@ -38,14 +38,16 @@ func InitApp() {
} }
// Seed admin account and JWT secret so the management console is // Seed admin account and JWT secret so the management console is
// immediately usable on a fresh install. Both are idempotent. // immediately usable on a fresh install. Both are idempotent.
_, isNew, err := data.EnsureDefaultAdmin() initialPassword, isNew, err := data.EnsureDefaultAdmin()
if err != nil { if err != nil {
color.Red.Printf("[bootstrap] ensure default admin err=%s\n", err) color.Red.Printf("[bootstrap] ensure default admin err=%s\n", err)
} }
if isNew { if isNew {
color.Yellow.Println("╔════════════════════════════════════════════════════════════════════════╗") color.Yellow.Println("╔════════════════════════════════════════════════════════════════════════╗")
color.Yellow.Println("║ Default admin account created. Fetch one-time password via API first!║") color.Yellow.Println("║ Default admin account created. Save these credentials now. ║")
color.Yellow.Printf("║ Username: admin ║\n") color.Yellow.Printf("║ Username: %-54s║\n", "admin")
color.Yellow.Printf("║ Password: %-54s║\n", initialPassword)
color.Yellow.Println("║ The one-time password API remains available until first fetch. ║")
color.Yellow.Println("║ GET /admin/api/v1/auth/init-password (one-time) ║") color.Yellow.Println("║ GET /admin/api/v1/auth/init-password (one-time) ║")
color.Yellow.Println("╚════════════════════════════════════════════════════════════════════════╝") color.Yellow.Println("╚════════════════════════════════════════════════════════════════════════╝")
} }