From 598f5dec1c97d212c7782ccbe357ec3eb0d54866 Mon Sep 17 00:00:00 2001 From: wkc <978997012@qq.com> Date: Mon, 11 May 2026 16:32:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=89=8D=E7=AB=AF=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=99=BB=E5=BD=95=E5=87=AD=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 ++ ...05-11-login-credential-frontend-cleanup.md | 35 +++++++++++++++++++ ruoyi-ui/src/views/login.vue | 12 +++---- 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 docs/reports/implementation/2026-05-11-login-credential-frontend-cleanup.md diff --git a/AGENTS.md b/AGENTS.md index 43db9a59..dcc82d1f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -67,6 +67,7 @@ - 前端相关安装、构建、调试、测试命令执行前,必须先通过 `nvm` 切换并确认 Node 版本 - 测试结束后,自动关闭测试过程中启动的前后端进程 - 重启后端时,必须优先使用 `bin/restart_java_backend.sh` +- 禁止在前端源码、配置、示例数据或页面默认值中硬编码或预填真实账号密码;登录页不得将密码保存到 Cookie、localStorage 或 sessionStorage --- @@ -257,6 +258,7 @@ return AjaxResult.success(result); - 请求统一使用 `@/utils/request` - 新增页面或功能入口时,同步检查 `sys_menu`、路由、权限标识 - 优先延续现有 `ccdi*` 业务目录与命名方式,不随意新造平行目录 +- 登录页只能在用户主动选择时保存用户名,不允许保存密码或预填默认密码 ### 导入功能规范 diff --git a/docs/reports/implementation/2026-05-11-login-credential-frontend-cleanup.md b/docs/reports/implementation/2026-05-11-login-credential-frontend-cleanup.md new file mode 100644 index 00000000..eb23aa9a --- /dev/null +++ b/docs/reports/implementation/2026-05-11-login-credential-frontend-cleanup.md @@ -0,0 +1,35 @@ +# 登录页前端凭据清理实施记录 + +## 背景 + +- 登录页存在默认预填账号 `admin` 和密码 `admin123`。 +- 登录页“记住密码”逻辑会把用户密码写入浏览器 Cookie。 +- 本次按要求移除前端代码中的账号密码,并将该类问题写入项目根 `AGENTS.md`。 + +## 修改内容 + +- 修改 `ruoyi-ui/src/views/login.vue`: + - 将登录表单默认 `username` 和 `password` 改为空字符串。 + - 将“记住密码”文案调整为“记住账号”。 + - 停止从 Cookie 读取密码,进入登录页时主动清理历史 `password` Cookie。 + - 停止登录时向 Cookie 写入密码,仅保留用户名记忆能力。 +- 修改 `AGENTS.md`: + - 增加禁止在前端源码、配置、示例数据或页面默认值中硬编码或预填真实账号密码的规则。 + - 增加登录页不得将密码保存到 Cookie、localStorage 或 sessionStorage 的规则。 + - 明确登录页最多只能保存用户名,不允许保存密码或预填默认密码。 + +## 影响范围 + +- 影响前端登录页默认展示与“记住”行为。 +- 不修改后端登录接口、账号认证逻辑、数据库用户密码哈希或权限体系。 +- 已存在于用户浏览器中的旧 `password` Cookie 会在访问登录页时被清理。 + +## 验证记录 + +- 源码检查:`rg -n "admin123|Cookies\\.set\\(\\\"password\\\"|Cookies\\.get\\(\\\"password\\\"|记住密码|decrypt\\(|encrypt\\(" ruoyi-ui/src -S` + - 结果:未命中登录页默认账号密码、密码 Cookie 读写和“记住密码”文案;仅保留 `jsencrypt.js` 通用工具函数定义。 +- 前端构建:`source ~/.nvm/nvm.sh && nvm use && node -v && npm run build:prod` + - 结果:Node `v14.21.3` 下构建成功;存在原有资源体积 warning。 +- 真实页面验证:启动前端开发服务后,使用 `browser-use` 打开 `http://127.0.0.1:8080/login`。 + - 结果:页面存在账号与密码输入框各 1 个,“记住账号”文案 1 个,“记住密码”文案 0 个,页面 DOM 不包含 `admin` 或 `admin123`。 +- 测试进程清理:已关闭本次启动的 `127.0.0.1:8080` 前端开发服务。 diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue index f209f762..d3aa6f95 100644 --- a/ruoyi-ui/src/views/login.vue +++ b/ruoyi-ui/src/views/login.vue @@ -37,7 +37,7 @@ - 记住密码 + 记住账号 import {getCodeImg} from "@/api/login" import Cookies from "js-cookie" -import {decrypt, encrypt} from '@/utils/jsencrypt' import defaultSettings from '@/settings' export default { @@ -75,8 +74,8 @@ export default { footerContent: defaultSettings.footerContent, codeUrl: "", loginForm: { - username: "admin", - password: "admin123", + username: "", + password: "", rememberMe: false, code: "", uuid: "" @@ -113,11 +112,11 @@ export default { }, getCookie() { const username = Cookies.get("username") - const password = Cookies.get("password") const rememberMe = Cookies.get('rememberMe') + Cookies.remove("password") this.loginForm = { username: username === undefined ? this.loginForm.username : username, - password: password === undefined ? this.loginForm.password : decrypt(password), + password: "", rememberMe: rememberMe === undefined ? false : Boolean(rememberMe) } }, @@ -127,7 +126,6 @@ export default { this.loading = true if (this.loginForm.rememberMe) { Cookies.set("username", this.loginForm.username, { expires: 30 }) - Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 }) Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 }) } else { Cookies.remove("username")