用户密码支持自定义配置规则

This commit is contained in:
RuoYi
2020-08-03 11:40:51 +08:00
parent 3d2d88287a
commit 8bf5140a72
7 changed files with 58 additions and 5 deletions

View File

@ -347,6 +347,32 @@ function calSumWidth(elements) {
return width;
}
/** 密码规则范围验证 */
function checkpwd(chrtype, password) {
if (chrtype == 1) {
if(!$.common.numValid(password)){
$.modal.alertWarning("密码只能为0-9数字");
return false;
}
} else if (chrtype == 2) {
if(!$.common.enValid(password)){
$.modal.alertWarning("密码只能为a-z和A-Z字母");
return false;
}
} else if (chrtype == 3) {
if(!$.common.enNumValid(password)){
$.modal.alertWarning("密码必须包含字母以及数字");
return false;
}
} else if (chrtype == 4) {
if(!$.common.charValid(password)){
$.modal.alertWarning("密码必须包含字母、数字、以及特殊符号-、_");
return false;
}
}
return true;
}
// 日志打印封装处理
var log = {
log: function(msg) {

View File

@ -1582,6 +1582,26 @@ var table = {
isMobile: function () {
return navigator.userAgent.match(/(Android|iPhone|SymbianOS|Windows Phone|iPad|iPod)/i);
},
// 数字正则表达式只能为0-9数字
numValid : function(text){
var patten = new RegExp(/^[0-9]+$/);
return patten.test(text);
},
// 英文正则表达式只能为a-z和A-Z字母
enValid : function(text){
var patten = new RegExp(/^[a-zA-Z]+$/);
return patten.test(text);
},
// 英文、数字正则表达式,必须包含(字母,数字)
enNumValid : function(text){
var patten = new RegExp(/^(?=.*[a-zA-Z]+)(?=.*[0-9]+)[a-zA-Z0-9]+$/);
return patten.test(text);
},
// 英文、数字、特殊字符正则表达式,必须包含(字母,数字,特殊字符-_
charValid : function(text){
var patten = new RegExp(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[-_])[A-Za-z\d-_]{6,}$/);
return patten.test(text);
},
}
});
})(jQuery);

View File

@ -221,7 +221,9 @@
});
function submitHandler() {
if ($.validate.form()) {
var chrtype = [[${@config.getKey('sys.account.chrtype')}]];
var password = $("#password").val();
if ($.validate.form() && checkpwd(chrtype, password)) {
var data = $("#form-user-add").serializeArray();
var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
var roleIds = $.form.selectCheckeds("role");
@ -233,7 +235,7 @@
}
}
/*用户管理-新增-选择部门树*/
/* 用户管理-新增-选择部门树 */
function selectDeptTree() {
var treeId = $("#treeId").val();
var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();

View File

@ -200,7 +200,7 @@
}
}
/*用户管理-修改-选择部门树*/
/* 用户管理-修改-选择部门树 */
function selectDeptTree() {
var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
var url = ctx + "system/dept/selectDeptTree/" + deptId;

View File

@ -283,7 +283,9 @@
});
function submitChangPassword () {
if ($.validate.form("form-user-resetPwd")) {
var chrtype = [[${@config.getKey('sys.account.chrtype')}]];
var password = $("#newPassword").val();
if ($.validate.form("form-user-resetPwd") && checkpwd(chrtype, password)) {
$.operate.saveModal(ctx + "system/user/profile/resetPwd", $('#form-user-resetPwd').serialize());
}
}

View File

@ -82,7 +82,9 @@
});
function submitHandler() {
if ($.validate.form()) {
var chrtype = [[${@config.getKey('sys.account.chrtype')}]];
var password = $("#newPassword").val();
if ($.validate.form() && checkpwd(chrtype, password)) {
$.operate.save(ctx + "system/user/profile/resetPwd", $('#form-user-resetPwd').serialize());
}
}