feat(user): 修改初始密码并增加密码强度验证
- 将初始密码从"666666"修改为"Jtys@123456"- 在用户修改密码时增加密码强度验证规则 - 弱密码用户登录时提示修改密码 - 优化密码修改逻辑,修改成功后自动登出dev
parent
30dfc667b5
commit
e8293f88d1
|
@ -60,9 +60,6 @@
|
|||
<el-form-item label="确认密码:" prop="newpassword1">
|
||||
<el-input v-model="userForm.newpassword1" type="password" auto-complete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="NAME">
|
||||
<el-input v-model="userForm.NAME" placeholder="这里输入姓名..." />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱" prop="EMAIL">
|
||||
<el-input v-model="userForm.EMAIL" placeholder="这里输入邮箱..." />
|
||||
</el-form-item>
|
||||
|
@ -140,6 +137,7 @@ import Screenfull from '@/components/Screenfull'
|
|||
import SizeSelect from '@/components/SizeSelect'
|
||||
import { requestFN } from '@/utils/request'
|
||||
import { upload } from '@/utils/upload'
|
||||
import { MessageBox } from 'element-ui'
|
||||
export default {
|
||||
components: {
|
||||
Breadcrumb,
|
||||
|
@ -150,8 +148,9 @@ export default {
|
|||
data() {
|
||||
const validatePass = (rule, value, callback) => {
|
||||
if (value) {
|
||||
if (value.toString().length < 1 || value.toString().length > 18) {
|
||||
callback(new Error('密码长度为6-18位'))
|
||||
var reg1 = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*.])[\da-zA-Z~!@#$%^&*.]{8,}$/
|
||||
if (!reg1.test(value)) {
|
||||
callback(new Error('密码必须是8位以上、必须包含大小写字母、数字、特殊符号'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
|
@ -207,7 +206,6 @@ export default {
|
|||
photoForm: {},
|
||||
userForm: {
|
||||
USERNAME: '',
|
||||
NAME: '',
|
||||
EMAIL: '',
|
||||
newpwd: '',
|
||||
newpassword1: ''
|
||||
|
@ -224,7 +222,6 @@ export default {
|
|||
]
|
||||
},
|
||||
userFormRules: {
|
||||
NAME: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
|
||||
|
||||
EMAIL: [
|
||||
{ required: false, message: '请输入邮箱', trigger: 'blur' },
|
||||
|
@ -396,7 +393,6 @@ export default {
|
|||
USERNAME: this.userForm.USERNAME,
|
||||
// NUMBER:this.userForm.NUMBER,
|
||||
PASSWORD: this.userForm.newpwd,
|
||||
NAME: this.userForm.NAME,
|
||||
PHONE: this.userForm.PHONE,
|
||||
EMAIL: this.userForm.EMAIL,
|
||||
DEPARTMENT_ID: this.DEPARTMENT_ID,
|
||||
|
@ -405,11 +401,22 @@ export default {
|
|||
BZ: this.userForm.BZ,
|
||||
OPERATIONTYPE: '1' }
|
||||
).then((data) => {
|
||||
if (this.userForm.newpwd) {
|
||||
MessageBox.alert('密码修改成功,请重新登录!', {
|
||||
confirmButtonText: '确定',
|
||||
callback: action => {
|
||||
sessionStorage.clear()
|
||||
this.goOut()
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Message({
|
||||
message: '信息修改成功',
|
||||
type: 'success',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
}
|
||||
this.dialogMessageEdit = false
|
||||
}).catch((e) => {
|
||||
})
|
||||
|
|
|
@ -13,18 +13,75 @@
|
|||
<el-button type="primary" @click="closeWarn">确 认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<el-dialog :visible.sync="dialogFormEdit" :before-close="handleClose" :append-to-body="true" title="登录的密码强度为弱,请修改密码!" width="600px">
|
||||
<div style="padding:0 40px">
|
||||
<el-form ref="userForm" :model="userForm" :rules="userFormRules" status-icon label-width="100px">
|
||||
<el-form-item label="用户名" >
|
||||
<el-input v-model="userForm.USERNAME" disabled placeholder="默认用户手机号码..." />
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码:" prop="newpwd">
|
||||
<el-input v-model="userForm.newpwd" type="password" auto-complete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码:" prop="newpassword1">
|
||||
<el-input v-model="userForm.newpassword1" type="password" auto-complete="off" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="text-align: center;margin-top:30px">
|
||||
<el-button type="primary" @click.native.prevent="editUser">确认修改</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
// import RaddarChart from './components/RaddarChart'
|
||||
/* eslint-disable */
|
||||
import { requestFN } from '@/utils/request'
|
||||
import { MessageBox } from 'element-ui'
|
||||
export default {
|
||||
components: {
|
||||
// RaddarChart
|
||||
},
|
||||
data() {
|
||||
const validatePass = (rule, value, callback) => {
|
||||
if (value.length < 1) {
|
||||
callback(new Error('密码不能为空'))
|
||||
}
|
||||
if (value) {
|
||||
var reg1 = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*.])[\da-zA-Z~!@#$%^&*.]{8,}$/
|
||||
if (!reg1.test(value)) {
|
||||
callback(new Error('密码必须是8位以上、必须包含大小写字母、数字、特殊符号'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const validatePass2 = (rule, value, callback) => {
|
||||
if (this.userForm.newpwd != '' && value === '') {
|
||||
callback(new Error('请再次输入密码'))
|
||||
} else if (value !== this.userForm.newpwd) {
|
||||
callback(new Error('两次输入密码不一致!'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
dialogFormEdit: false,
|
||||
userForm: {
|
||||
USERNAME: '',
|
||||
newpwd: '',
|
||||
newpassword1: ''
|
||||
},
|
||||
userFormRules: {
|
||||
newpwd: [
|
||||
{ required: true, validator: validatePass, trigger: 'blur' }
|
||||
],
|
||||
newpassword1: [
|
||||
{ required: true, validator: validatePass2, trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
dialogWarnEnable: false,
|
||||
custom: '',
|
||||
riskData: {}
|
||||
|
@ -33,8 +90,17 @@ export default {
|
|||
created() {
|
||||
// this.getRiskData()
|
||||
this.implementationReminder()
|
||||
if (JSON.parse(sessionStorage.getItem('user')).passwordType === '0') {
|
||||
this.dialogFormEdit = true
|
||||
}
|
||||
this.userForm.USERNAME = JSON.parse(sessionStorage.getItem('user')).USERNAME
|
||||
},
|
||||
methods: {
|
||||
handleClose(done) {
|
||||
if (!this.dialogFormEdit) {
|
||||
done()
|
||||
}
|
||||
},
|
||||
// 是否实施逾期提醒
|
||||
implementationReminder(){
|
||||
requestFN(
|
||||
|
@ -49,6 +115,56 @@ export default {
|
|||
}).catch((e) => {
|
||||
})
|
||||
},
|
||||
editUser() {
|
||||
this.$refs.userForm.validate(valid => {
|
||||
if (valid) {
|
||||
requestFN(
|
||||
'/user/editUserOwn',
|
||||
{ USER_ID: this.USER_ID,
|
||||
USERNAME: this.userForm.USERNAME,
|
||||
PASSWORD: this.userForm.newpwd,
|
||||
NAME: this.userForm.NAME,
|
||||
PHONE: this.userForm.PHONE,
|
||||
EMAIL: this.userForm.EMAIL,
|
||||
DEPARTMENT_ID: this.DEPARTMENT_ID,
|
||||
POST_ID: this.userForm.POST_ID,
|
||||
BZ: this.userForm.BZ,
|
||||
OPERATIONTYPE: '1' }
|
||||
).then((data) => {
|
||||
MessageBox.alert('密码修改成功,请重新登录!', {
|
||||
confirmButtonText: '确定',
|
||||
callback: action => {
|
||||
sessionStorage.clear()
|
||||
this.goOut()
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
this.dialogFormEdit = false
|
||||
}).catch((e) => {
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
// 下线
|
||||
goOut: function(msg) {
|
||||
requestFN(
|
||||
'/main/logout',
|
||||
{}
|
||||
).then((data) => {
|
||||
// this.fwebsocket.close()
|
||||
sessionStorage.clear()
|
||||
window.location.href = localStorage.getItem('out_url')
|
||||
// window.location.href = 'http://192.168.0.112:8080/'
|
||||
})
|
||||
.catch((e) => {
|
||||
// this.fwebsocket.close()
|
||||
sessionStorage.clear()
|
||||
window.location.href = localStorage.getItem('out_url')
|
||||
// window.location.href = 'http://192.168.0.112:8080/'
|
||||
})
|
||||
},
|
||||
closeWarn(){
|
||||
this.dialogWarnEnable = false
|
||||
this.custom = ''
|
||||
|
|
|
@ -779,7 +779,7 @@ export default {
|
|||
})
|
||||
},
|
||||
resetPwd(id) {
|
||||
this.$confirm('确定要重置密码为666666吗?', {
|
||||
this.$confirm('确定要重置密码为Jtys@123456吗?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
|
|
|
@ -344,7 +344,7 @@ export default {
|
|||
})
|
||||
},
|
||||
resetPwd(id, name) {
|
||||
this.$confirm('是否重置密码为666666?', {
|
||||
this.$confirm('是否重置密码为Jtys@123456?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
|
|
|
@ -360,7 +360,7 @@ export default {
|
|||
})
|
||||
},
|
||||
resetPwd(id, username) {
|
||||
this.$confirm('是否重置密码为666666?', {
|
||||
this.$confirm('是否重置密码为Jtys@123456?', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
|
|
|
@ -136,7 +136,7 @@ export default {
|
|||
LEARNERCATEGORYSTATUS: 'select',
|
||||
SORT: '',
|
||||
DEPARTUREDESCR: '',
|
||||
PASSWORD: '666666',
|
||||
PASSWORD: 'Jtys@123456',
|
||||
USERAVATARPREFIX: '',
|
||||
USERAVATARURL: '',
|
||||
USERAVATARURL_CONVERT: '',
|
||||
|
|
Loading…
Reference in New Issue