Commit 93f63616 by liangjianmin

feat(menu): 增加初始密码强制修改功能和密码强度校验

- 在菜单组件中添加通用密码强度验证函数
- 修改密码表单中新增密码校验规则,要求包含字母和数字且长度不少于6位
- 增加对用户初始密码状态的检测,首次登录强制弹出修改密码对话框
- 新增提示信息,提醒用户及时更换初始密码
- 优化用户信息获取逻辑,统一初始密码检测处理
- 增加提交修改密码表单的验证逻辑
parent d4ae64e1
Showing with 43 additions and 5 deletions
......@@ -24,3 +24,4 @@ pnpm-debug.log*
/.cursor
/.cursor
/.cursor
......@@ -277,6 +277,18 @@
name: 'menus',
props: {},
data() {
// 密码强度验证函数 - 通用
var validatePassword = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入新密码'))
} else if (value.length < 6) {
callback(new Error('密码至少6位'))
} else if (!/[a-zA-Z]/.test(value) || !/\d/.test(value)) {
callback(new Error('密码需同时包含英文字母和数字'))
} else {
callback()
}
}
var validatePass2 = (rule, value, callback) => {
if (value === '') {
callback(new Error('请再次输入密码'))
......@@ -361,8 +373,8 @@
}],
password: [{
required: true,
message: '请输入新密码',
trigger: 'blur'
trigger: 'blur',
validator: validatePassword
}],
repassword: [{
required: true,
......@@ -383,8 +395,8 @@
}],
password: [{
required: true,
message: '请输入新密码',
trigger: 'blur'
trigger: 'blur',
validator: validatePassword
}],
repassword: [{
required: true,
......@@ -722,11 +734,33 @@
getData() {
if (window.userInfo) {
this.userinfo = window.userInfo;
// 检查是否为初始密码
if (this.userinfo.is_init_passwd == 1) {
this.changePwd();
setTimeout(() => {
this.$message({
message: '请及时更换初始密码',
type: 'warning',
duration: 3000
});
}, 100);
}
} else {
this.$http('get', "/api/user/getuserinfo").then(res => {
if (res.code == 0) {
this.userinfo = res.data;
window.userInfo = res.data
window.userInfo = res.data;
// 检查是否为初始密码
if (res.data.is_init_passwd == 1) {
this.changePwd();
setTimeout(() => {
this.$message({
message: '请及时更换初始密码',
type: 'warning',
duration: 3000
});
}, 100);
}
}
})
}
......@@ -974,6 +1008,9 @@
handleSelect(key, keyPath) {
this.tabss(key)
},
/**
* 原密码验证修改密码
*/
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment