LAPTOP-FO2T5SIU\35838 недель назад: 4
Родитель
Сommit
5427e45355
3 измененных файлов с 28 добавлено и 24 удалено
  1. 19 5
      src/static/utils/validate.js
  2. 1 11
      src/views/components/updatePassword.vue
  3. 8 8
      src/views/system/user.vue

+ 19 - 5
src/static/utils/validate.js

@@ -120,17 +120,31 @@ export function validateURL(textval) {
 
 /* 验证内容是否英文数字以及下划线*/
 export function isPassword(rule, value, callback) {
-    const reg = /^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{8,}$/
-    //console.log('new pwd: ', value, reg.test(value))
-    if (value === '') {
-        callback(new Error('请输入密码'))
+    // const reg = /^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{8,}$/
+    const reg = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*])(?!.*\s).{8,}$/
+
+    if (value.length < 8) {
+        callback(new Error('密码不可小于8位'))
     } else if (!reg.test(value)) {
-        callback(new Error('密码需由大小写字母及数字组成'))
+        callback(new Error('密码需由至少8位大小写字母、数字及符号组成'))
+    } else if (checkPasswordContain(value)) {
+        callback(new Error('密码不可包含常用复数数字或指定简易密码'))
     } else {
         callback()
     }
 }
 
+function checkPasswordContain(value) {
+    const blackList = ['123456', '654321', '123456!', '654321!', 'Xiaoai@2024', 'idea@',
+        '000', '111', '222', '333', '444', '555', '666', '777', '888', '999']
+
+    for (let i = 0; i < blackList.length; i++) {
+        if (value.indexOf(blackList[i]) > -1) return true
+    }
+
+    return false
+}
+
 /* 自动检验数值的范围*/
 export function checkMax20000(rule, value, callback) {
     if (value === '' || value === undefined || value === null) {

+ 1 - 11
src/views/components/updatePassword.vue

@@ -80,17 +80,7 @@ export default {
                     }
                 ],
                 newPwd: [
-                    { required: true, trigger: 'blur', validator: isPassword },
-                    {
-                        validator: (rule, value, callback) => {
-                            if (value.length < 8) {
-                                callback(new Error('密码不可小于8位'))
-                            } else {
-                                callback()
-                            }
-                        },
-                        trigger: 'blur'
-                    }
+                    { required: true, trigger: 'blur', validator: isPassword }
                 ],
                 newPwdConfirm: [
                     { required: true, message: '确认密码', trigger: 'blur' },

+ 8 - 8
src/views/system/user.vue

@@ -315,12 +315,12 @@
                         <el-input v-model="form.comment" :rows="2" type="textarea" />
                       </el-form-item>
                     </el-col>
-                      <el-col :span="3" class="col-txt"><span>初始密码</span></el-col>
-                      <el-col :span="9" class="col-input">
-                          <el-form-item>
-                              <el-input v-model="defaultPassword" readonly/>
-                          </el-form-item>
-                      </el-col>
+<!--                      <el-col :span="3" class="col-txt"><span>初始密码</span></el-col>-->
+<!--                      <el-col :span="9" class="col-input">-->
+<!--                          <el-form-item>-->
+<!--                              <el-input v-model="defaultPassword" readonly/>-->
+<!--                          </el-form-item>-->
+<!--                      </el-col>-->
                   </el-row>
                 </el-col>
               </el-row>
@@ -975,7 +975,7 @@ export default {
         },
         /* 批量重置密码*/
         resetPassword: function(val, isBatch) {
-            let info = '是否批量重置密码为:' + this.defaultPassword + '?'
+            let info = '是否批量重置密码?(系统参数码:DEFAULT_PASSWORD)'
             let soaUrl = 'editPwd'
             const postData = { password: this.$md5(this.defaultPassword) }
             if (!isBatch) {
@@ -984,7 +984,7 @@ export default {
                     return
                 }
 
-                info = '是否将' + val.username + '密码重置为默认密码:' + this.defaultPassword + '?'
+                info = '是否将' + val.username + '密码重置为默认密码?(系统参数码:DEFAULT_PASSWORD)'
                 postData.id = val.id
                 soaUrl = 'editPwd'
             } else {