|
@@ -79,6 +79,11 @@ $(document).ready(() => {
|
|
|
if (!/^[0-9a-zA-Z*~!@&%$^\\(\\)#_\[\]\-\+={}|?'":,<>.`]+$/.test(resetPassword)) {
|
|
|
throw '密码只支持英文数字及符号';
|
|
|
}
|
|
|
+ // 判断新密码的强度
|
|
|
+ const reg = /^(?![0-9]+$)(?![a-zA-Z]+$).{6,16}$/;
|
|
|
+ if (!reg.test(resetPassword)) {
|
|
|
+ throw '请设置至少包含数字和字母的密码';
|
|
|
+ }
|
|
|
const btn = $(this);
|
|
|
$.ajax({
|
|
|
url: '/setting/user/reset/password',
|
|
@@ -425,6 +430,11 @@ function checkPasswordForm() {
|
|
|
if (!/^[0-9a-zA-Z*~!@&%$^\\(\\)#_\[\]\-\+={}|?'":,<>.`]+$/.test(resetPassword)) {
|
|
|
throw '密码只支持英文数字及符号';
|
|
|
}
|
|
|
+ // 判断新密码的强度
|
|
|
+ const reg = /^(?![0-9]+$)(?![a-zA-Z]+$).{6,16}$/;
|
|
|
+ if (!reg.test(resetPassword)) {
|
|
|
+ throw '请设置至少包含数字和字母的密码';
|
|
|
+ }
|
|
|
} catch (err) {
|
|
|
toastr.error(err);
|
|
|
return false;
|
|
@@ -449,6 +459,11 @@ function checkUserForm(status) {
|
|
|
if (!/^[0-9a-zA-Z*~!@&%$^\\(\\)#_\[\]\-\+={}|?'":,<>.`]+$/.test($('#add-user input[name="password"]').val())) {
|
|
|
throw '密码只支持英文数字及符号';
|
|
|
}
|
|
|
+ // 判断新密码的强度
|
|
|
+ const reg = /^(?![0-9]+$)(?![a-zA-Z]+$).{6,16}$/;
|
|
|
+ if (!reg.test($('#add-user input[name="password"]').val())) {
|
|
|
+ throw '请设置至少包含数字和字母的密码';
|
|
|
+ }
|
|
|
if ($('#add-user input[name="name"]').val() == '') {
|
|
|
throw '姓名不能为空';
|
|
|
}
|
|
@@ -513,23 +528,25 @@ function checkUnitForm() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 随机密码
|
|
|
+ * 随机密码(必须包含数字和字母)
|
|
|
*/
|
|
|
function randPassword() {
|
|
|
- let result = '';
|
|
|
+ const result = [];
|
|
|
// 随机6-10位
|
|
|
- const length = Math.ceil(Math.random() * 2 + 8);
|
|
|
+ const length = Math.ceil(Math.random() * 2 + 6);
|
|
|
let numberSeed = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
|
let stringSeed = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
|
|
|
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
|
|
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
|
|
-
|
|
|
+ const numRan = numberSeed[Math.floor((Math.random() * numberSeed.length))];
|
|
|
+ const strRan = stringSeed[Math.floor((Math.random() * stringSeed.length))];
|
|
|
const randSeed = stringSeed.concat(numberSeed);
|
|
|
const seedLength = randSeed.length - 1;
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
const index = Math.ceil(Math.random() * seedLength);
|
|
|
- result += randSeed[index];
|
|
|
+ result.push(randSeed[index]);
|
|
|
}
|
|
|
-
|
|
|
- return result;
|
|
|
+ result.splice(Math.floor((Math.random() * result.length)), 0, numRan);
|
|
|
+ result.splice(Math.floor((Math.random() * result.length)), 0, strRan);
|
|
|
+ return result.join('');
|
|
|
}
|