From 9c58c5b07929c308d32a66272a4b7bbfc5e7e971 Mon Sep 17 00:00:00 2001 From: xuans Date: Thu, 1 Oct 2026 21:00:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=AF=86=E7=A0=81=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E6=8E=A5=E5=8F=A3=E6=9C=AC=E6=9C=BA=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=A0=87=E8=AF=86=E5=B9=B6=E6=89=A9=E5=A4=A7=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E5=9B=9E=E5=BD=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/httpapi/password_reset_account.go | 2 +- backend/internal/httpapi/password_reset_local_test.go | 6 +++--- backend/internal/httpapi/server.go | 2 +- frontend/src/views/PasswordReset/PasswordReset.test.js | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/backend/internal/httpapi/password_reset_account.go b/backend/internal/httpapi/password_reset_account.go index 37d6c53..8d04244 100644 --- a/backend/internal/httpapi/password_reset_account.go +++ b/backend/internal/httpapi/password_reset_account.go @@ -50,7 +50,7 @@ func (s *Server) resolvePasswordResetAccount(c *gin.Context) { AccountLabel: "超级管理员", Title: "超级管理员密码重置", Description: "已识别为超级管理员账户。该账户不能通过普通重置页面修改密码,请联系系统管理员按照服务器本机安全维护流程处理。", - Action: "local_admin_command", + Action: "contact_administrator", }) return } diff --git a/backend/internal/httpapi/password_reset_local_test.go b/backend/internal/httpapi/password_reset_local_test.go index 2626816..2338b47 100644 --- a/backend/internal/httpapi/password_reset_local_test.go +++ b/backend/internal/httpapi/password_reset_local_test.go @@ -8,7 +8,7 @@ import ( "testing" ) -func TestPasswordResetResolutionOnlyOffersLocalAdminCommand(t *testing.T) { +func TestPasswordResetResolutionOnlyOffersAdministratorContact(t *testing.T) { cfg := readyTestConfig(t.TempDir()) cfg.Admin.Username = "owner" cfg.Admin.Email = "owner@example.test" @@ -30,10 +30,10 @@ func TestPasswordResetResolutionOnlyOffersLocalAdminCommand(t *testing.T) { if err := json.Unmarshal(response.Body.Bytes(), &payload); err != nil { t.Fatal(err) } - if payload["account_type"] != "super_admin" || payload["action"] != "local_admin_command" { + if payload["account_type"] != "super_admin" || payload["action"] != "contact_administrator" { t.Fatalf("超级管理员没有返回受控本机处理标识:%v", payload) } - if description, _ := payload["description"].(string); strings.Contains(strings.ToLower(description), "scert-admin") || strings.Contains(description, "systemctl") { + if description := strings.ToLower(response.Body.String()); strings.Contains(description, "scert-admin") || strings.Contains(description, "systemctl") || strings.Contains(description, "local_admin_command") { t.Fatalf("公开查询不应泄露本机管理命令:%s", description) } for _, field := range []string{"reset_path", "reset_url", "token", "nonce"} { diff --git a/backend/internal/httpapi/server.go b/backend/internal/httpapi/server.go index d2b4940..bc04c01 100644 --- a/backend/internal/httpapi/server.go +++ b/backend/internal/httpapi/server.go @@ -525,7 +525,7 @@ func (s *Server) status(c *gin.Context) { if _, authenticated := s.currentAuthSession(c); authenticated { payload["https_mode"] = cfg.Server.HTTPSMode payload["database_driver"] = cfg.Database.Driver - payload["reset_method"] = "local_admin_command" + payload["reset_method"] = "contact_administrator" } c.JSON(http.StatusOK, payload) } diff --git a/frontend/src/views/PasswordReset/PasswordReset.test.js b/frontend/src/views/PasswordReset/PasswordReset.test.js index 342c958..a168ca3 100644 --- a/frontend/src/views/PasswordReset/PasswordReset.test.js +++ b/frontend/src/views/PasswordReset/PasswordReset.test.js @@ -20,7 +20,7 @@ function elements(node, predicate, matches = []) { test("超级管理员查询保留本机处理标识,不生成网页重置链接", async (t) => { const payload = { account_type: "super_admin", - action: "local_admin_command", + action: "contact_administrator", title: "超级管理员密码重置", description: "请在部署主机操作。", }; @@ -32,8 +32,9 @@ test("超级管理员查询保留本机处理标识,不生成网页重置链 }); state.identifier.value = " owner "; await state.submit(); - assert.equal(state.resolution.value.action, "local_admin_command"); + assert.equal(state.resolution.value.action, "contact_administrator"); assert.equal("reset_path" in state.resolution.value, false); + assert.doesNotMatch(JSON.stringify(state.resolution.value), /local_admin_command|systemctl|scert-admin/iu); assert.equal(state.error.value, ""); assert.equal(state.submitting.value, false); state.reset();