feat(admin): add authenticated restart endpoint + fix admin username
- POST /api/v1/admin/restart: admin-only restart (forks new process) - Fix: MemUserStore now uses cfg.AdminUsername instead of hardcoded 'admin' - RestartFunc injected by main.go for clean process fork + exit
This commit is contained in:
1 parent
dee48b6766
commit
628d416dcd
4 files changed
+115
-6
No files matched your search
@@ -28,14 +28,16 @@ type MemUserStore struct {
|
||||
users map[string]*UserRecord
|
||||
}
|
||||
|
||||
// NewMemUserStore creates an in-memory user store with a default admin.
|
||||
func NewMemUserStore(adminPassword string) *MemUserStore {
|
||||
// NewMemUserStore creates an in-memory user store with the configured admin account.
|
||||
func NewMemUserStore(adminUsername, adminPassword string) *MemUserStore {
|
||||
s := &MemUserStore{users: make(map[string]*UserRecord)}
|
||||
|
||||
hash, _ := auth.HashPassword(adminPassword)
|
||||
s.users["admin"] = &UserRecord{
|
||||
UserID: "admin", Username: "admin",
|
||||
PasswordHash: hash, Role: "admin",
|
||||
s.users[adminUsername] = &UserRecord{
|
||||
UserID: adminUsername,
|
||||
Username: adminUsername,
|
||||
PasswordHash: hash,
|
||||
Role: "admin",
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user