mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-06 18:00:57 +00:00
[Feature] 增加功能,安全设置(全局MFA设置,密码强度校验)
This commit is contained in:
@@ -609,3 +609,91 @@ function setUrlParam(url, name, value) {
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
// 校验密码-改变规则颜色
|
||||
function checkPasswordRules(password, minLength) {
|
||||
if (wordMinLength(password, minLength)) {
|
||||
$('#rule_SECURITY_PASSWORD_MIN_LENGTH').css('color', 'green')
|
||||
}
|
||||
else {
|
||||
$('#rule_SECURITY_PASSWORD_MIN_LENGTH').css('color', '#908a8a')
|
||||
}
|
||||
|
||||
if (wordUpperCase(password)) {
|
||||
$('#rule_SECURITY_PASSWORD_UPPER_CASE').css('color', 'green');
|
||||
}
|
||||
else {
|
||||
$('#rule_SECURITY_PASSWORD_UPPER_CASE').css('color', '#908a8a')
|
||||
}
|
||||
|
||||
if (wordLowerCase(password)) {
|
||||
$('#rule_SECURITY_PASSWORD_LOWER_CASE').css('color', 'green')
|
||||
}
|
||||
else {
|
||||
$('#rule_SECURITY_PASSWORD_LOWER_CASE').css('color', '#908a8a')
|
||||
}
|
||||
|
||||
if (wordNumber(password)) {
|
||||
$('#rule_SECURITY_PASSWORD_NUMBER').css('color', 'green')
|
||||
}
|
||||
else {
|
||||
$('#rule_SECURITY_PASSWORD_NUMBER').css('color', '#908a8a')
|
||||
}
|
||||
|
||||
if (wordSpecialChar(password)) {
|
||||
$('#rule_SECURITY_PASSWORD_SPECIAL_CHAR').css('color', 'green')
|
||||
}
|
||||
else {
|
||||
$('#rule_SECURITY_PASSWORD_SPECIAL_CHAR').css('color', '#908a8a')
|
||||
}
|
||||
}
|
||||
|
||||
// 最小长度
|
||||
function wordMinLength(word, minLength) {
|
||||
//var minLength = {{ min_length }};
|
||||
var re = new RegExp("^(.{" + minLength + ",})$");
|
||||
return word.match(re)
|
||||
}
|
||||
// 大写字母
|
||||
function wordUpperCase(word) {
|
||||
return word.match(/([A-Z]+)/)
|
||||
}
|
||||
// 小写字母
|
||||
function wordLowerCase(word) {
|
||||
return word.match(/([a-z]+)/)
|
||||
}
|
||||
// 数字字符
|
||||
function wordNumber(word) {
|
||||
return word.match(/([\d]+)/)
|
||||
}
|
||||
// 特殊字符
|
||||
function wordSpecialChar(word) {
|
||||
return word.match(/[`,~,!,@,#,\$,%,\^,&,\*,\(,\),\-,_,=,\+,\{,\},\[,\],\|,\\,;,',:,",\,,\.,<,>,\/,\?]+/)
|
||||
}
|
||||
|
||||
// 显示弹窗密码规则
|
||||
function popoverPasswordRules(password_check_rules, $el) {
|
||||
var message = "";
|
||||
jQuery.each(password_check_rules, function (idx, rules) {
|
||||
message += "<li id=" + rules.id + " style='list-style-type:none;'> <i class='fa fa-check-circle-o' style='margin-right:10px;' ></i>" + rules.label + "</li>";
|
||||
});
|
||||
//$('#id_password_rules').html(message);
|
||||
$el.html(message)
|
||||
}
|
||||
|
||||
// 初始化弹窗popover
|
||||
function initPopover($container, $progress, $idPassword, $el, password_check_rules){
|
||||
options = {};
|
||||
// User Interface
|
||||
options.ui = {
|
||||
container: $container,
|
||||
viewports: {
|
||||
progress: $progress
|
||||
//errors: $('.popover-content')
|
||||
},
|
||||
showProgressbar: true,
|
||||
showVerdictsInsideProgressBar: true
|
||||
};
|
||||
$idPassword.pwstrength(options);
|
||||
popoverPasswordRules(password_check_rules, $el);
|
||||
}
|
||||
|
Reference in New Issue
Block a user