Kaynağa Gözat

修改密码验证修改

xieqy 3 yıl önce
ebeveyn
işleme
9fc32162d8
2 değiştirilmiş dosya ile 6 ekleme ve 4 silme
  1. 1 0
      src/utils/reg.ts
  2. 5 4
      src/views/login/index.vue

+ 1 - 0
src/utils/reg.ts

@@ -3,6 +3,7 @@
 export const regPhone = () => /^1[3456789]\d{9}$/ // 手机号码验证
 export const regEmail = () => /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/ // 邮箱验证
 export const regPassword = () => /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9!@#$%&+-]{8,16}$/ // 密码强度验证
+export const regNewPassword = () => /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9!@#$%&+-]{12,}$/ // 密码强度验证
 //export const regUserName = () => /^[a-zA-Z0-9_-]{4,16}$/ // 用户姓名正则
 export const regNewUserName = () => /^[A-Za-z0-9_]+$/ // 用户姓名正则 限制字符、数字、下划线
 export const regUserName = () => /^[A-Za-z0-9]+$/ // 用户姓名正则 限制字符、数字

+ 5 - 4
src/views/login/index.vue

@@ -20,7 +20,7 @@
           class="login-form middle"
           auto-complete="on"
           label-position="left"
-          style="position: relative;top: 200px; left: calc((100% - 320px)/2);top: 150px;"
+          style="position: relative; top: 200px; left: calc((100% - 320px) / 2); top: 150px"
         >
           <el-input
             ref="username"
@@ -94,7 +94,7 @@
 import { Vue, Component, Watch } from 'vue-property-decorator'
 import { userFirstLogin } from '@/api/user'
 import { changePassword } from '@/api/base'
-import { regPassword } from '@/utils/reg'
+import { regNewPassword } from '@/utils/reg'
 import { ElForm } from 'element-ui/types/form'
 const sha1Hex = require('sha1-hex')
 const defaultPwd = '000000'
@@ -141,8 +141,8 @@ export default class Login extends Vue {
       callback(new Error('请输入密码!'))
     } else {
       if (this.changePwd.pass !== '') {
-        if (!regPassword().test(value)) {
-          callback(new Error('密码位数8-16位,必须包含大小写字母和数字,不可包含非法字符!'))
+        if (!regNewPassword().test(value)) {
+          callback(new Error('密码位数至少12位,必须包含大小写字母和数字,不可包含非法字符!'))
           return
         }
       }
@@ -284,6 +284,7 @@ export default class Login extends Vue {
               this.loading = false
               this.changePwd.pass = ''
               this.changePwd.checkPass = ''
+              this.loginForm.password = ''
               sessionStorage.clear()
             } else {
               this.$nextTick(() => {