Commit 71af5fac authored by zL's avatar zL

fix:对密码设置进行正则校验

parent b4f7c8fd
// 8~20位包含数字、大小写字母
export function validPassword(pwd) {
const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/
return reg.test(pwd)
}
......@@ -41,6 +41,7 @@
</template>
<script >
import Vue from "vue";
import { validPassword } from "@/utils/tool/validate";
import CodeBtn from "./VerCode.vue";
import { editPassword } from "./Api.service";
export default Vue.extend({
......@@ -74,10 +75,15 @@ export default Vue.extend({
});
},
async confirm() {
if (this.passwordForm.pwd.trim() === "") {
this.$message("密码不可为空");
// 密码格式校验
if (!validPassword(this.passwordForm.pwd)) {
this.$message({
message: "用户密码错误",
type: "error",
});
return;
} else if (this.passwordForm.code.trim() === "") {
}
if (this.passwordForm.code.trim() === "") {
this.$message("验证码不可为空");
return;
}
......@@ -109,7 +115,6 @@ export default Vue.extend({
message: "密码修改成功",
type: "success",
});
// this.$notify.success(res.message);
this.$router.push("/userCenter");
}
},
......
......@@ -41,6 +41,7 @@
</template>
<script>
import Vue from "vue";
import { validPassword } from "@/utils/tool/validate";
import CodeBtn from "./VerCode.vue";
import { editPassword } from "./Api.service";
export default Vue.extend({
......@@ -74,10 +75,15 @@ export default Vue.extend({
});
},
async confirm() {
if (this.passwordForm.pwd.trim() === "") {
this.$message("密码不可为空");
// 密码格式校验
if (!validPassword(this.passwordForm.pwd)) {
this.$message({
message: "用户密码错误",
type: "error",
});
return;
} else if (this.passwordForm.code.trim() === "") {
}
if (this.passwordForm.code.trim() === "") {
this.$message("验证码不可为空");
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment