优化密码校验
This commit is contained in:
parent
7b389d7632
commit
e6188797f6
|
|
@ -89,6 +89,6 @@ export function isArray(arg) {
|
|||
|
||||
// 密码规则:8-20位,必须包含字母、数字、特殊字符中的两种
|
||||
export function validPassword(str) {
|
||||
const reg = /^((?=.*[A-Za-z])(?=.*\d)|(?=.*[A-Za-z])(?=.*[!@#$%^&*()_+\-\=])|(?=.*\d)(?=.*[!@#$%^&*()_+\-\=]))[A-Za-z\d!@#$%^&*()_+\-\=]{8,20}$/
|
||||
const reg = /^(?!.*(?:111|888|123|234|345|456|567|678|789|1234|2345|3456|4567|5678|6789|12345|23456|34567|45678|56789|abc|abcd|abcde|abcdef|abcdefg|qwe|qwer|qwert|qwerty|asdf|asdfg|asdfgh|password|passw0rd|letmein|welcome|admin|user|test|pass|root|login))(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!@#$%^&*()_+{}\[\]:;"'|\\,.<>\/?~-]).{8,16}$/
|
||||
return reg.test(str)
|
||||
}
|
||||
|
|
@ -380,6 +380,14 @@ export default {
|
|||
trigger: 'blur',
|
||||
message: '请输入您的密码',
|
||||
},
|
||||
{
|
||||
min: 8,
|
||||
max: 16,
|
||||
pattern:
|
||||
/^(?!.*(?:111|888|123|234|345|456|567|678|789|1234|2345|3456|4567|5678|6789|12345|23456|34567|45678|56789|abc|abcd|abcde|abcdef|abcdefg|qwe|qwer|qwert|qwerty|asdf|asdfg|asdfgh|password|passw0rd|letmein|welcome|admin|user|test|pass|root|login))(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!@#$%^&*()_+{}\[\]:;"'|\\,.<>\/?~-]).{8,16}$/,
|
||||
message: '请输入正确的登录密码',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
code: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,26 +1,48 @@
|
|||
<template>
|
||||
<div class="login">
|
||||
<div class="login-bar">
|
||||
<div class="form-bar">
|
||||
<h3 class="title">请重置登录密码</h3>
|
||||
<el-form ref="form" :model="user" :rules="rules">
|
||||
<el-form-item label="旧密码" prop="oldPassword">
|
||||
<el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" show-password />
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="newPassword">
|
||||
<el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" show-password />
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
<el-input v-model="user.confirmPassword" placeholder="请确认新密码" type="password" show-password />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" style="width: 48.5%" @click="submit">确认修改</el-button>
|
||||
<el-button style="width: 48.5%" @click="close">返回登录页</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="login">
|
||||
<div class="login-bar">
|
||||
<div class="form-bar">
|
||||
<h3 class="title">请重置登录密码</h3>
|
||||
<el-form ref="form" :model="user" :rules="rules">
|
||||
<el-form-item label="旧密码" prop="oldPassword">
|
||||
<el-input
|
||||
v-model="user.oldPassword"
|
||||
placeholder="请输入旧密码"
|
||||
type="password"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="newPassword">
|
||||
<el-input
|
||||
v-model="user.newPassword"
|
||||
placeholder="请输入新密码"
|
||||
type="password"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
<el-input
|
||||
v-model="user.confirmPassword"
|
||||
placeholder="请确认新密码"
|
||||
type="password"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
style="width: 48.5%"
|
||||
@click="submit"
|
||||
>确认修改</el-button
|
||||
>
|
||||
<el-button style="width: 48.5%" @click="close"
|
||||
>返回登录页</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
|
@ -29,185 +51,198 @@ import { validPassword } from '@/utils/validate'
|
|||
import { encrypt } from '@/utils/jsencrypt.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
const passwordRegex = (rule, value, callback) => {
|
||||
if (value.length < 8 || value.length > 20) {
|
||||
callback(new Error('密码长度在 8 到 20 个字符'))
|
||||
} else if (!validPassword(value)) {
|
||||
callback(new Error('密码须包含数字、字母、特殊符号中的两种以上'))
|
||||
} else if (this.user.oldPassword === value) {
|
||||
callback(new Error('新密码不能与旧密码相同'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const equalToPassword = (rule, value, callback) => {
|
||||
if (this.user.newPassword !== value) {
|
||||
callback(new Error('两次输入的密码不一致'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
user: {
|
||||
oldPassword: undefined,
|
||||
newPassword: undefined,
|
||||
confirmPassword: undefined,
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
oldPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: '旧密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
newPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: '新密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
validator: passwordRegex,
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
confirmPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: '确认密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
validator: equalToPassword,
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
this.$refs['form'].validate(valid => {
|
||||
if (valid) {
|
||||
const oldPassword = encrypt(this.user.oldPassword)
|
||||
const newPassword = encrypt(this.user.newPassword)
|
||||
updateUserPwd(oldPassword, newPassword).then(response => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
// 进入首页
|
||||
this.$store.dispatch('LogOut').then(() => {
|
||||
location.href = process.env.NODE_ENV === 'production' ? '/sgzbgl/login' : '/login'
|
||||
// location.href = process.env.NODE_ENV === 'production' ? '/gl/login' : '/login'
|
||||
})
|
||||
})
|
||||
data() {
|
||||
const passwordRegex = (rule, value, callback) => {
|
||||
if (
|
||||
value.length < 8 ||
|
||||
value.length > 16 ||
|
||||
!validPassword(value)
|
||||
) {
|
||||
callback(
|
||||
new Error(
|
||||
'请设置8到16位,由字母、数字、特殊字符3种组合,且数字不可连续的密码',
|
||||
),
|
||||
)
|
||||
return false
|
||||
} else if (this.user.oldPassword === value) {
|
||||
callback(new Error('新密码不能与旧密码相同'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const equalToPassword = (rule, value, callback) => {
|
||||
if (this.user.newPassword !== value) {
|
||||
callback(new Error('两次输入的密码不一致'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
user: {
|
||||
oldPassword: undefined,
|
||||
newPassword: undefined,
|
||||
confirmPassword: undefined,
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
oldPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: '旧密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
newPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: '新密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
validator: passwordRegex,
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
confirmPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: '确认密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
validator: equalToPassword,
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
})
|
||||
},
|
||||
close() {
|
||||
this.$store.dispatch('LogOut').then(() => {
|
||||
location.href = process.env.NODE_ENV === 'production' ? '/sgzbgl/login' : '/login'
|
||||
// location.href = process.env.NODE_ENV === 'production-nw' ? '/gl/login' : '/login'
|
||||
})
|
||||
methods: {
|
||||
submit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
const oldPassword = encrypt(this.user.oldPassword)
|
||||
const newPassword = encrypt(this.user.newPassword)
|
||||
updateUserPwd(oldPassword, newPassword).then((response) => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
// 进入首页
|
||||
this.$store.dispatch('LogOut').then(() => {
|
||||
location.href =
|
||||
process.env.NODE_ENV === 'production'
|
||||
? '/sgzbgl/login'
|
||||
: '/login'
|
||||
// location.href = process.env.NODE_ENV === 'production' ? '/gl/login' : '/login'
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
close() {
|
||||
this.$store.dispatch('LogOut').then(() => {
|
||||
location.href =
|
||||
process.env.NODE_ENV === 'production'
|
||||
? '/sgzbgl/login'
|
||||
: '/login'
|
||||
// location.href = process.env.NODE_ENV === 'production-nw' ? '/gl/login' : '/login'
|
||||
})
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss">
|
||||
.login {
|
||||
//display: flex;
|
||||
//justify-content: center;
|
||||
//align-items: center;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
background-image: url('../assets/images/login.png');
|
||||
background-size: 100% 100%;
|
||||
//background: #1891FF;
|
||||
//display: flex;
|
||||
//justify-content: center;
|
||||
//align-items: center;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
background-image: url('../assets/images/login.png');
|
||||
background-size: 100% 100%;
|
||||
//background: #1891FF;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 0px auto 30px auto;
|
||||
//text-align: center;
|
||||
color: #707070;
|
||||
margin: 0px auto 30px auto;
|
||||
//text-align: center;
|
||||
color: #707070;
|
||||
}
|
||||
|
||||
.login-bar {
|
||||
position: absolute;
|
||||
height: auto;
|
||||
top: 20%;
|
||||
left: 14%;
|
||||
width: auto;
|
||||
height: 500px;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
background: #fff;
|
||||
text-align: center;
|
||||
padding-top: 40px;
|
||||
position: absolute;
|
||||
height: auto;
|
||||
top: 20%;
|
||||
left: 14%;
|
||||
width: auto;
|
||||
height: 500px;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
background: #fff;
|
||||
text-align: center;
|
||||
padding-top: 40px;
|
||||
}
|
||||
|
||||
.form-bar {
|
||||
//height: 500px;
|
||||
width: 360px;
|
||||
background: #fff;
|
||||
//height: 500px;
|
||||
width: 360px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
//border-radius: 6px;
|
||||
//height: 100%;
|
||||
background: #ffffff;
|
||||
width: 400px;
|
||||
padding: 25px 25px 5px 25px;
|
||||
//border-radius: 6px;
|
||||
//height: 100%;
|
||||
background: #ffffff;
|
||||
width: 400px;
|
||||
padding: 25px 25px 5px 25px;
|
||||
|
||||
.el-input {
|
||||
height: 45px;
|
||||
.el-input {
|
||||
height: 45px;
|
||||
|
||||
input {
|
||||
height: 38px;
|
||||
input {
|
||||
height: 38px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.input-icon {
|
||||
height: 39px;
|
||||
width: 14px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
.input-icon {
|
||||
height: 39px;
|
||||
width: 14px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.login-tip {
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
color: #bfbfbf;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
color: #bfbfbf;
|
||||
}
|
||||
|
||||
.login-code {
|
||||
width: 33%;
|
||||
height: 38px;
|
||||
float: right;
|
||||
width: 33%;
|
||||
height: 38px;
|
||||
float: right;
|
||||
|
||||
img {
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
}
|
||||
img {
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
.el-login-footer {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-family: Arial;
|
||||
font-size: 12px;
|
||||
letter-spacing: 1px;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-family: Arial;
|
||||
font-size: 12px;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.login-code-img {
|
||||
height: 38px;
|
||||
height: 38px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -135,17 +135,17 @@
|
|||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="info"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-upload2"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleImport"-->
|
||||
<!-- v-hasPermi="['system:user:import']"-->
|
||||
<!-- >导入</el-button-->
|
||||
<!-- >-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="info"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-upload2"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleImport"-->
|
||||
<!-- v-hasPermi="['system:user:import']"-->
|
||||
<!-- >导入</el-button-->
|
||||
<!-- >-->
|
||||
<!-- </el-col>-->
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
|
|
@ -539,14 +539,14 @@
|
|||
|
||||
<script>
|
||||
import {
|
||||
listUser,
|
||||
getUser,
|
||||
delUser,
|
||||
addUser,
|
||||
updateUser,
|
||||
resetUserPwd,
|
||||
changeUserStatus,
|
||||
deptTreeSelect,
|
||||
listUser,
|
||||
getUser,
|
||||
delUser,
|
||||
addUser,
|
||||
updateUser,
|
||||
resetUserPwd,
|
||||
changeUserStatus,
|
||||
deptTreeSelect,
|
||||
} from '@/api/system/user'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
|
|
@ -666,9 +666,12 @@ export default {
|
|||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
min: 5,
|
||||
max: 20,
|
||||
message: '用户密码长度必须介于 5 和 20 之间',
|
||||
min: 8,
|
||||
max: 16,
|
||||
pattern:
|
||||
/^(?!.*(?:111|888|123|234|345|456|567|678|789|1234|2345|3456|4567|5678|6789|12345|23456|34567|45678|56789|abc|abcd|abcde|abcdef|abcdefg|qwe|qwer|qwert|qwerty|asdf|asdfg|asdfgh|password|passw0rd|letmein|welcome|admin|user|test|pass|root|login))(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!@#$%^&*()_+{}\[\]:;"'|\\,.<>\/?~-]).{8,16}$/,
|
||||
message:
|
||||
'请设置8到16位,由字母、数字、特殊字符3种组合,且数字不可连续的密码',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
|
|
@ -834,12 +837,14 @@ export default {
|
|||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
closeOnClickModal: false,
|
||||
inputPattern: /^.{5,20}$/,
|
||||
inputErrorMessage: '用户密码长度必须介于 5 和 20 之间',
|
||||
inputPattern:
|
||||
/^(?!.*(?:111|888|123|234|345|456|567|678|789|1234|2345|3456|4567|5678|6789|12345|23456|34567|45678|56789|abc|abcd|abcde|abcdef|abcdefg|qwe|qwer|qwert|qwerty|asdf|asdfg|asdfgh|password|passw0rd|letmein|welcome|admin|user|test|pass|root|login))(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!@#$%^&*()_+{}\[\]:;"'|\\,.<>\/?~-]).{8,16}$/,
|
||||
inputErrorMessage:
|
||||
'请设置8到16位,由字母、数字、特殊字符3种组合,且数字不可连续的密码',
|
||||
})
|
||||
.then(({ value }) => {
|
||||
const password = encrypt(value)
|
||||
resetUserPwd(row.userId, password).then((response) => {
|
||||
const password = encrypt(value)
|
||||
resetUserPwd(row.userId, password).then((response) => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,83 +1,127 @@
|
|||
<template>
|
||||
<el-form ref="form" :model="user" :rules="rules" label-width="80px">
|
||||
<el-form-item label="旧密码" prop="oldPassword">
|
||||
<el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" show-password/>
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="newPassword">
|
||||
<el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" show-password/>
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
<el-input v-model="user.confirmPassword" placeholder="请确认新密码" type="password" show-password/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="mini" @click="submit">保存</el-button>
|
||||
<el-button type="danger" size="mini" @click="close">关闭</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-form ref="form" :model="user" :rules="rules" label-width="80px">
|
||||
<el-form-item label="旧密码" prop="oldPassword">
|
||||
<el-input
|
||||
v-model="user.oldPassword"
|
||||
placeholder="请输入旧密码"
|
||||
type="password"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="newPassword">
|
||||
<el-input
|
||||
v-model="user.newPassword"
|
||||
placeholder="请输入新密码"
|
||||
type="password"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="confirmPassword">
|
||||
<el-input
|
||||
v-model="user.confirmPassword"
|
||||
placeholder="请确认新密码"
|
||||
type="password"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="mini" @click="submit"
|
||||
>保存</el-button
|
||||
>
|
||||
<el-button type="danger" size="mini" @click="close">关闭</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { updateUserPwd } from "@/api/system/user";
|
||||
import { updateUserPwd } from '@/api/system/user'
|
||||
import { validPassword } from '@/utils/validate'
|
||||
import { encrypt } from '@/utils/jsencrypt.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
const passwordRegex = (rule, value, callback) => {
|
||||
if (value.length < 8 || value.length > 20) {
|
||||
callback(new Error("密码长度在 8 到 20 个字符"));
|
||||
} else if (!validPassword(value)) {
|
||||
callback(new Error("密码须包含数字、字母、特殊符号中的两种以上"));
|
||||
} else if (this.user.oldPassword === value) {
|
||||
callback(new Error('新密码不能与旧密码相同'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const equalToPassword = (rule, value, callback) => {
|
||||
if (this.user.newPassword !== value) {
|
||||
callback(new Error("两次输入的密码不一致"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
return {
|
||||
user: {
|
||||
oldPassword: undefined,
|
||||
newPassword: undefined,
|
||||
confirmPassword: undefined
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
oldPassword: [
|
||||
{ required: true, message: "旧密码不能为空", trigger: "blur" }
|
||||
],
|
||||
newPassword: [
|
||||
{ required: true, message: "新密码不能为空", trigger: "blur" },
|
||||
{ required: true, validator: passwordRegex, trigger: "blur" }
|
||||
],
|
||||
confirmPassword: [
|
||||
{ required: true, message: "确认密码不能为空", trigger: "blur" },
|
||||
{ required: true, validator: equalToPassword, trigger: "blur" }
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
const oldPassword = encrypt(this.user.oldPassword)
|
||||
const newPassword = encrypt(this.user.newPassword)
|
||||
updateUserPwd(oldPassword, newPassword).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
});
|
||||
data() {
|
||||
const passwordRegex = (rule, value, callback) => {
|
||||
if (
|
||||
value.length < 8 ||
|
||||
value.length > 16 ||
|
||||
!validPassword(value)
|
||||
) {
|
||||
callback(
|
||||
new Error(
|
||||
'请设置8到16位,由字母、数字、特殊字符3种组合,且数字不可连续的密码',
|
||||
),
|
||||
)
|
||||
return false
|
||||
} else if (this.user.oldPassword === value) {
|
||||
callback(new Error('新密码不能与旧密码相同'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const equalToPassword = (rule, value, callback) => {
|
||||
if (this.user.newPassword !== value) {
|
||||
callback(new Error('两次输入的密码不一致'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
user: {
|
||||
oldPassword: undefined,
|
||||
newPassword: undefined,
|
||||
confirmPassword: undefined,
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
oldPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: '旧密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
newPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: '新密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
validator: passwordRegex,
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
confirmPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: '确认密码不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
validator: equalToPassword,
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
});
|
||||
},
|
||||
close() {
|
||||
this.$tab.closePage();
|
||||
}
|
||||
}
|
||||
};
|
||||
methods: {
|
||||
submit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
const oldPassword = encrypt(this.user.oldPassword)
|
||||
const newPassword = encrypt(this.user.newPassword)
|
||||
updateUserPwd(oldPassword, newPassword).then((response) => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
close() {
|
||||
this.$tab.closePage()
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ module.exports = {
|
|||
|
||||
// target: `http://192.168.2.76:28080`, //超
|
||||
// target: `http://10.40.92.81:8080`, //韩/
|
||||
// target: `http://192.168.2.76:28080`,//旭/
|
||||
target: `http://192.168.2.248:28080`, //帅
|
||||
target: `http://192.168.2.76:28080`,//旭/
|
||||
// target: `http://192.168.2.248:28080`, //帅
|
||||
// target: `http://10.40.92.253:28080`, //福
|
||||
|
||||
//******** 注意事项 ********* */
|
||||
|
|
|
|||
Loading…
Reference in New Issue