Sfoglia il codice sorgente

新增密码复杂性校验

chensibo 18 ore fa
parent
commit
5361d5769a
1 ha cambiato i file con 20 aggiunte e 0 eliminazioni
  1. 20 0
      src/views/system/user/index.vue

+ 20 - 0
src/views/system/user/index.vue

@@ -771,11 +771,31 @@ export default {
         this.form.password = "";
       });
     },
+    // 密码复杂性校验方法
+    validatePassword(value) {
+      if (!value) {
+        return "密码不能为空";
+      }
+      if (value.length < 6) {
+        return "密码长度至少6位";
+      }
+      if (!/[a-zA-Z]/.test(value)) {
+        return "密码必须包含字母";
+      }
+      if (!/\d/.test(value)) {
+        return "密码必须包含数字";
+      }
+      if (!/[~!@#$%^&*_+]/.test(value)) {
+        return "密码必须包含英文特殊符号(~!@#$%^&*_+)";
+      }
+      return true;
+    },
     /** 重置密码按钮操作 */
     handleResetPwd(row) {
       this.$prompt('请输入"' + row.username + '"的新密码', "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
+        inputValidator: this.validatePassword,
       })
         .then(({ value }) => {
           resetUserPwd(row.id, value).then((response) => {