fix: restore default admin password and add reset flag
Some checks failed
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

Restored 'admin123' as the default password in db init and added a -reset-admin flag to main.go.
This commit is contained in:
2026-03-19 11:22:11 -04:00
parent 45c2d5e643
commit 7d43b2c31b
2 changed files with 18 additions and 2 deletions

View File

@@ -1,16 +1,22 @@
package main
import (
"flag"
"log"
"os"
"llm-proxy/internal/config"
"llm-proxy/internal/db"
"llm-proxy/internal/server"
"github.com/joho/godotenv"
"golang.org/x/crypto/bcrypt"
)
func main() {
resetAdmin := flag.Bool("reset-admin", false, "Reset admin password to admin123")
flag.Parse()
// Load environment variables
if err := godotenv.Load(); err != nil {
log.Println("No .env file found")
@@ -28,6 +34,16 @@ func main() {
log.Fatalf("Failed to initialize database: %v", err)
}
if *resetAdmin {
hash, _ := bcrypt.GenerateFromPassword([]byte("admin123"), 12)
_, err = database.Exec("UPDATE users SET password_hash = ?, must_change_password = 1 WHERE username = 'admin'", string(hash))
if err != nil {
log.Fatalf("Failed to reset admin password: %v", err)
}
log.Println("Admin password has been reset to 'admin123'")
os.Exit(0)
}
// Initialize server
s := server.NewServer(cfg, database)