From 1e9340bbda89715f4b266a92bd4e4e493baa2f62 Mon Sep 17 00:00:00 2001 From: wkc <978997012@qq.com> Date: Fri, 3 Apr 2026 10:45:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=99=BB=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=B4=A6=E5=8F=B7=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...04-03-login-default-credentials-removed.md | 14 +++++++++ ruoyi-ui/src/views/login.vue | 4 +-- .../tests/login-default-credentials.test.js | 30 +++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 doc/implementation-report-2026-04-03-login-default-credentials-removed.md create mode 100644 ruoyi-ui/tests/login-default-credentials.test.js diff --git a/doc/implementation-report-2026-04-03-login-default-credentials-removed.md b/doc/implementation-report-2026-04-03-login-default-credentials-removed.md new file mode 100644 index 0000000..b93d63c --- /dev/null +++ b/doc/implementation-report-2026-04-03-login-default-credentials-removed.md @@ -0,0 +1,14 @@ +# 2026-04-03 登录页默认账号密码移除实施记录 + +## 修改内容 +- 移除登录页 `ruoyi-ui/src/views/login.vue` 中硬编码的默认账号 `admin` 与默认密码 `admin123`。 +- 保留 `getCookie()` 现有逻辑,确保用户勾选“记住密码”后仍可通过 cookie 回填登录信息。 +- 新增前端回归脚本 `ruoyi-ui/tests/login-default-credentials.test.js`,校验默认值为空且 cookie 回填逻辑未被破坏。 + +## 验证记录 +- 变更前执行 `node tests/login-default-credentials.test.js`,断言“登录页默认用户名应为空字符串”失败,证明问题可复现。 +- 变更后再次执行 `node tests/login-default-credentials.test.js`,预期全部断言通过。 +- 启动前端页面后在浏览器访问登录页,确认账号、密码输入框默认不再预填内容。 + +## 影响范围 +- 仅影响登录页初始化展示行为,不修改登录接口、加密逻辑、验证码逻辑与记住密码逻辑。 diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue index dde986d..228ea43 100644 --- a/ruoyi-ui/src/views/login.vue +++ b/ruoyi-ui/src/views/login.vue @@ -75,8 +75,8 @@ export default { footerContent: defaultSettings.footerContent, codeUrl: "", loginForm: { - username: "admin", - password: "admin123", + username: "", + password: "", rememberMe: false, code: "", uuid: "" diff --git a/ruoyi-ui/tests/login-default-credentials.test.js b/ruoyi-ui/tests/login-default-credentials.test.js new file mode 100644 index 0000000..39bf690 --- /dev/null +++ b/ruoyi-ui/tests/login-default-credentials.test.js @@ -0,0 +1,30 @@ +const fs = require('fs') +const path = require('path') +const assert = require('assert') + +const loginViewSource = fs.readFileSync( + path.join(__dirname, '../src/views/login.vue'), + 'utf8' +) + +assert( + /loginForm:\s*\{[\s\S]*username:\s*""/.test(loginViewSource), + '登录页默认用户名应为空字符串' +) + +assert( + /loginForm:\s*\{[\s\S]*password:\s*""/.test(loginViewSource), + '登录页默认密码应为空字符串' +) + +assert( + /username:\s*username === undefined \? this\.loginForm\.username : username/.test(loginViewSource), + '登录页应继续支持从 cookie 回填用户名' +) + +assert( + /password:\s*password === undefined \? this\.loginForm\.password : decrypt\(password\)/.test(loginViewSource), + '登录页应继续支持从 cookie 回填密码' +) + +console.log('login default credentials assertions passed')