自动化立体仓库 - WMS系统
Junjie
2023-03-14 6b3886b0c39410d48a5ca6c578f9d664fa75c844
增加密码复杂度验证
4个文件已修改
57 ■■■■■ 已修改文件
src/main/webapp/static/js/common.js 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/index.html 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/login.html 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/password.html 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/common.js
@@ -5,6 +5,22 @@
// 详情窗口-宽度
var detailWidth = '90%';
function checkPassword(password) {
    //密码必须包含字符和数字长度不能少于8位
    let pattern = /(?=.*[0-9])(?=.*[a-zA-Z!@#$]).{8,}/
    //不能包含连续数字
    let pattern2 = /(0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){3}\d/
    //重复数字不能超过四位
    let pattern3 = /(\d)\1{3}/
    if (pattern.test(password) && pattern2.test(password) === false && pattern3.test(password) === false) {
        //匹配放行
        return true
    }
    //不匹配要求修改密码
    return false;
}
// 非空判断
function isEmpty(obj){
    return typeof obj == "undefined" || obj == null || obj === "";
src/main/webapp/views/index.html
@@ -52,7 +52,7 @@
          <cite id="username" style="margin-right: 5px">管理员</cite>
        </a>
        <dl class="layui-nav-child">
          <dd lay-unselect><a ew-href="detail.html?resourceId=8">基本资料</a></dd>
          <dd lay-unselect><a id="personPage" ew-href="detail.html?resourceId=8">基本资料</a></dd>
          <hr>
          <dd lay-unselect><a id="logout">退出</a></dd>
        </dl>
@@ -160,6 +160,28 @@
    var url = logout.getAttribute('href');
    logout.setAttribute('href', baseUrl + "/login");
    let username = localStorage.getItem('username')
    let password = localStorage.getItem('password')
    if (!(username === 'super' || password === 'root')) {
      if(!checkPassword(password)){
        //要求修改密码
        layer.msg('弱密码请修改密码再继续', {icon: 2});
        layer.open({
          type: 2,
          title: '基本资料',
          maxmin: true,
          shadeClose: false,
          area: [top.detailWidth, top.detailHeight],
          content: 'detail.html',
          closeBtn: 0,
          success: function(layero, index){
            layero.find('.layui-layer-min').remove(); //去掉最小化按钮
            layero.find('.layui-layer-max').remove(); //去掉最大化按钮
          }
        })
      }
    }
  });
</script>
<script type="text/html" id="menuTpl">
src/main/webapp/views/login.html
@@ -133,6 +133,7 @@
            if (res.code === 200){
              localStorage.setItem("token", res.data.token);
              localStorage.setItem("username", res.data.username);
              localStorage.setItem("password", password);
              window.location.href = "index.html";
            } else if (res.code === 10001) {
              layer.tips(res.msg, '#username', {tips: [4, '#ff0000']});
src/main/webapp/views/password.html
@@ -91,11 +91,27 @@
                if (parent.$('#password').val() === hex_md5(val)) {
                    return "与旧密码不能相同";
                }
                let username = localStorage.getItem('username')
                if (!(username === 'super' || password === 'root')){
                    if(!checkPassword(val)){
                        //密码必须包含字符和数字
                        return "密码必须包含字符和数字长度不能少于8位,且不能包含连续数字和四位重复数字";
                    }
                }
            },
            rePwd: function (val) {
                if ($('#password').val() !== val){
                    return "密码不一致";
                }
                let username = localStorage.getItem('username')
                if (!(username === 'super' || password === 'root')){
                    if(!checkPassword(val)){
                        //密码必须包含字符和数字
                        return "密码必须包含字符和数字长度不能少于8位,且不能包含连续数字和四位重复数字";
                    }
                }
            }
        });