移除前端默认登录凭据
This commit is contained in:
@@ -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*` 业务目录与命名方式,不随意新造平行目录
|
||||
- 登录页只能在用户主动选择时保存用户名,不允许保存密码或预填默认密码
|
||||
|
||||
### 导入功能规范
|
||||
|
||||
|
||||
@@ -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` 前端开发服务。
|
||||
@@ -37,7 +37,7 @@
|
||||
<img :src="codeUrl" @click="getCode" class="login-code-img"/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
|
||||
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住账号</el-checkbox>
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button
|
||||
:loading="loading"
|
||||
@@ -64,7 +64,6 @@
|
||||
<script>
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user