|
@@ -346,31 +346,45 @@ const getDtl = (row) => {
|
|
|
});
|
|
|
};
|
|
|
const newPassword = () => {
|
|
|
- formData.data.password = generatePassword();
|
|
|
+ formData.data.password = generatePassword1();
|
|
|
};
|
|
|
-const generatePassword = () => {
|
|
|
- var length = 12,
|
|
|
- charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
|
|
|
- password = "";
|
|
|
- for (var i = 0, n = charset.length; i < length; ++i) {
|
|
|
- password += charset.charAt(Math.floor(Math.random() * n));
|
|
|
+const generatePassword1 = () => {
|
|
|
+ //随机生成一个密码,必须包含大小写和数字,且不能有连续三个相同的字符
|
|
|
+ const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
|
+ const passwordLength = 10; // 密码长度,你可以根据需要调整
|
|
|
+ var password1 = '';
|
|
|
+
|
|
|
+ for (let i = 0; i < passwordLength; i++) {
|
|
|
+ // 随机选择一个字符
|
|
|
+ const randomChar = chars.charAt(Math.floor(Math.random() * chars.length));
|
|
|
+
|
|
|
+ // 如果前两个字符是相同的,并且当前字符不是大写,那么我们就选择一个大写字符
|
|
|
+ if (i < 2 && password1.length < 2 && randomChar === password1[password1.length - 1]) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果前三个字符是相同的,并且当前字符是大写,那么我们就选择一个小写字符
|
|
|
+ if (i < 3 && password1.length < 3 && randomChar === password1[password1.length - 1] && randomChar === password1[password1.length - 2] && randomChar.toUpperCase() === password1[password1.length - 2]) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ password1 += randomChar;
|
|
|
}
|
|
|
- return password;
|
|
|
+ return password1;
|
|
|
};
|
|
|
const userId = ref("");
|
|
|
const password = ref("");
|
|
|
const roomDialogVisible = ref(false);
|
|
|
const submitPassword = (password1) => {
|
|
|
- if (!password1) {
|
|
|
+ //正则判断密码构成 必须有大写小写数字,而且不能有连续三个相同的字符
|
|
|
+ const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?!.*([a-zA-Z0-9])\1{2}).{8,16}$/;
|
|
|
+ if (!reg.test(password1)) {
|
|
|
ElMessage({
|
|
|
- message: "请输入新密码",
|
|
|
+ message: "密码必须有大写小写数字,而且不能有连续三个相同的字符",
|
|
|
type: "warning",
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
- if (password1.length < 5) {
|
|
|
- return ElMessage("密码长度不得低于五位");
|
|
|
- }
|
|
|
proxy
|
|
|
.post(
|
|
|
"/tenantUser/resetPwd",
|