diff --git a/src/internal/admin/handlers.go b/src/internal/admin/handlers.go index 26277b3..81814b2 100644 --- a/src/internal/admin/handlers.go +++ b/src/internal/admin/handlers.go @@ -338,6 +338,7 @@ func (s *Server) handleUserAdd(w http.ResponseWriter, r *http.Request) { s.redirect(w, r, s.p(""), "error: "+err.Error()) return } + _ = s.db.AddAuditLog("000+"+name, "user.create") // The password is always auto-generated and shown once. cred := "user: " + res.User.Name + "\npassword: " + res.Password + @@ -359,6 +360,7 @@ func (s *Server) handleUserDel(w http.ResponseWriter, r *http.Request) { s.redirect(w, r, s.p(""), "error: "+err.Error()) return } + _ = s.db.AddAuditLog("000+"+name, "user.delete") s.redirect(w, r, s.p(""), s.t(r, "user_deleted", name)) } @@ -392,6 +394,7 @@ func (s *Server) handleUserQuota(w http.ResponseWriter, r *http.Request) { s.redirect(w, r, s.p(""), "error: "+err.Error()) return } + _ = s.db.AddAuditLog("000+"+name, "quota.update") s.redirect(w, r, s.p(""), s.t(r, "quota_updated", name)) } @@ -440,6 +443,7 @@ func (s *Server) handleResetPanelPass(w http.ResponseWriter, r *http.Request) { return } panel := s.cfg.PanelURL("/" + s.cfg.Panel.URLPath) + _ = s.db.AddAuditLog("000+"+name, "passwd.reset") s.redirectModal(w, r, s.p(""), s.t(r, "new_panel_password", name, pass, panel)) } @@ -474,6 +478,7 @@ func (s *Server) handleAdminPass(w http.ResponseWriter, r *http.Request) { if c, err := r.Cookie("vpsmgr_admin_session"); err == nil { s.sessions.clearExcept(c.Value) } + _ = s.db.AddAuditLog("000", "admin.passwd") s.redirect(w, r, s.p(""), s.t(r, "admin_pass_changed")) } @@ -637,6 +642,7 @@ func (s *Server) handleBlockedDomains(w http.ResponseWriter, r *http.Request) { s.redirect(w, r, s.p("/domains"), "error: "+err.Error()) return } + _ = s.db.AddAuditLog("000", "blocked.update") if len(bad) > 0 { lines := make([]string, 0, len(bad)) for _, n := range bad { diff --git a/src/internal/admin/templates/admin_audit.html b/src/internal/admin/templates/admin_audit.html index 8cfcccc..1725f79 100644 --- a/src/internal/admin/templates/admin_audit.html +++ b/src/internal/admin/templates/admin_audit.html @@ -73,7 +73,14 @@ var ACT={ 'power.restart':{zh:'重启',en:'restart'}, 'reinstall':{zh:'重装系统',en:'reinstall'}, 'reset_root_password':{zh:'重置 root 密码',en:'reset root password'}, - 'domain_update':{zh:'更新域名配置',en:'update domain config'} + 'domain_update':{zh:'更新域名配置',en:'update domain config'}, + 'user.create':{zh:'创建用户',en:'create user'}, + 'user.delete':{zh:'删除用户',en:'delete user'}, + 'passwd.change':{zh:'修改面板密码',en:'change panel password'}, + 'passwd.reset':{zh:'重置面板密码',en:'reset panel password'}, + 'admin.passwd':{zh:'修改管理员密码',en:'change admin password'}, + 'quota.update':{zh:'修改配额',en:'update quota'}, + 'blocked.update':{zh:'修改封禁域名列表',en:'update blocked domains'} }; function actLabel(a){var m=ACT[a]||{};return LANG==='zh'?(m.zh||a):(m.en||a);} function pad2(n){return (n<10?'0':'')+n;} diff --git a/src/internal/panel/handlers.go b/src/internal/panel/handlers.go index 257d7c2..5c7aa2a 100644 --- a/src/internal/panel/handlers.go +++ b/src/internal/panel/handlers.go @@ -228,6 +228,7 @@ func (s *Server) handlePanelPassword(w http.ResponseWriter, r *http.Request) { s.redirect(w, r, s.p(""), "error: "+err.Error()) return } + _ = s.db.AddAuditLog(u.Name, "passwd.change") s.redirect(w, r, s.p(""), "ok: panel password changed") }