ztxkutils 2.10.38 → 2.10.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export { c as authority } from './authority-e6bde99f.js';
|
2
2
|
export { d as dataModel } from './dataModel-1fbaff40.js';
|
3
3
|
export { t as tools } from './tools-09a4d620.js';
|
4
|
-
export { v as validate } from './validate-
|
4
|
+
export { v as validate } from './validate-a06e1fa0.js';
|
5
5
|
export { r as request } from './request-8e2b5826.js';
|
6
6
|
export { r as reqUrl } from './reqUrl-787dd9e5.js';
|
7
7
|
import './tslib.es6-35653116.js';
|
@@ -71,6 +71,19 @@ var commonMessage = {
|
|
71
71
|
passwordMessage: '密码必须包含大小写字母、数字、特殊字符且最小长度为8,且不能出现连续数字或字符,不能出现相同字符,且禁止使用用户账号作为密码',
|
72
72
|
spaceMessage: '请勿输入空格',
|
73
73
|
};
|
74
|
+
function isConsecutiveChars(char1, char2) {
|
75
|
+
var lowerCaseAlphabet = 'abcdefghijklmnopqrstuvwxyz'; // 小写字母
|
76
|
+
var upperCaseAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 大写字母
|
77
|
+
var numeric = '0123456789'; // 数字
|
78
|
+
// 找到包含两个字符的字符集
|
79
|
+
var alphabet = [lowerCaseAlphabet, upperCaseAlphabet, numeric].find(function (alph) { return alph.includes(char1) && alph.includes(char2); });
|
80
|
+
if (!alphabet) {
|
81
|
+
return false; // 如果两个字符不在同一字符集中,那么它们不可能连续
|
82
|
+
}
|
83
|
+
var index1 = alphabet.indexOf(char1);
|
84
|
+
var index2 = alphabet.indexOf(char2);
|
85
|
+
return Math.abs(index1 - index2) === 1; // 如果两个字符在字符集中的位置相邻,那么它们是连续的
|
86
|
+
}
|
74
87
|
function validatePassword(password, username) {
|
75
88
|
// 用正则表达式检查密码基本规则
|
76
89
|
var regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$/;
|
@@ -80,13 +93,26 @@ function validatePassword(password, username) {
|
|
80
93
|
message: '密码中必须包含大小写字母、数字、特殊字符,且长度必须大于8个字符!',
|
81
94
|
};
|
82
95
|
}
|
83
|
-
// 检查密码中是否有连续的字母或数字
|
96
|
+
// 检查密码中是否有连续的字母或数字 连续超过三次
|
97
|
+
var count = 0;
|
98
|
+
var startChart = 0;
|
84
99
|
for (var i = 0; i < password.length - 1; i++) {
|
85
|
-
if (
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
100
|
+
if (isConsecutiveChars(password[i], password[i + 1])) {
|
101
|
+
if (count === 0) {
|
102
|
+
startChart = i;
|
103
|
+
}
|
104
|
+
count++;
|
105
|
+
if (count >= 2) {
|
106
|
+
// 密码中不应含有连续的字母或数字
|
107
|
+
return {
|
108
|
+
result: false,
|
109
|
+
message: "\u4ECE\u7B2C" + (startChart + 1) + "\u4E2A\u5B57\u7B26\u5F00\u59CB\uFF0C\u6709\u8FDE\u7EED\u8D85\u8FC7\u4E09\u4F4D\u7684\u5B57\u6BCD\u6216\u6570\u5B57!",
|
110
|
+
};
|
111
|
+
}
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
count = 0;
|
115
|
+
startChart = 0;
|
90
116
|
}
|
91
117
|
}
|
92
118
|
// 检查密码中是否有相同的字符
|
package/dist/validate.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { c as commonMessage, b as validate, a as validatePassword } from './validate-
|
1
|
+
export { c as commonMessage, b as validate, a as validatePassword } from './validate-a06e1fa0.js';
|