[update] 修改bug88595,修改密码加密
This commit is contained in:
@@ -17,10 +17,12 @@
|
||||
<a-input :placeholder="$t('pleaseEnter') + $t('user.userAccount')" v-decorator="[ 'username', {}]" :readOnly="true"/>
|
||||
</a-form-item>
|
||||
|
||||
<!-- 登录密码 -->
|
||||
<a-form-item :label="$t('user.loginPassword')" :labelCol="labelCol" :wrapperCol="wrapperCol" :hasFeedback="true" >
|
||||
<a-input type="password" :placeholder="$t('pleaseEnter') + $t('user.loginPassword')" v-decorator="[ 'password', validatorRules.password]" />
|
||||
</a-form-item>
|
||||
|
||||
<!-- 确认密码 -->
|
||||
<a-form-item :label="$t('user.confirmPassword')" :labelCol="labelCol" :wrapperCol="wrapperCol" :hasFeedback="true" >
|
||||
<a-input type="password" @blur="handleConfirmBlur" :placeholder="$t('user.reenterLoginPassword')" v-decorator="[ 'confirmpassword', validatorRules.confirmpassword]"/>
|
||||
</a-form-item>
|
||||
@@ -32,6 +34,8 @@
|
||||
|
||||
<script>
|
||||
import { changePassword } from '@/api/api'
|
||||
import { JSEncrypt } from 'jsencrypt'
|
||||
import { getRSAPublicKey } from '../../../utils/encryption'
|
||||
|
||||
export default {
|
||||
name: 'PasswordModal',
|
||||
@@ -71,7 +75,8 @@ export default {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 16 }
|
||||
},
|
||||
form: this.$form.createForm(this)
|
||||
form: this.$form.createForm(this),
|
||||
rsaPublicKey: ''
|
||||
}
|
||||
},
|
||||
created () {
|
||||
@@ -94,23 +99,39 @@ export default {
|
||||
this.selectedRole = []
|
||||
},
|
||||
handleSubmit () {
|
||||
// 触发表单验证
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
this.confirmLoading = true
|
||||
const formData = Object.assign(this.model, values)
|
||||
changePassword(formData).then((res) => {
|
||||
if (res.success) {
|
||||
this.$message.success(res.message)
|
||||
this.$emit('ok')
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
// 先拉取秘钥
|
||||
getRSAPublicKey().then(res => {
|
||||
this.rsaPublicKey = res.result
|
||||
// 触发表单验证
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
this.confirmLoading = true
|
||||
const formData = Object.assign(this.model, values)
|
||||
// 对密码进行加密
|
||||
const encrypt = new JSEncrypt()
|
||||
encrypt.setPublicKey(this.rsaPublicKey)
|
||||
|
||||
// 登录密码
|
||||
if (formData.password) {
|
||||
formData.password = encrypt.encrypt(formData.password)
|
||||
}
|
||||
}).finally(() => {
|
||||
this.confirmLoading = false
|
||||
this.close()
|
||||
})
|
||||
}
|
||||
// 确认密码
|
||||
if (formData.confirmpassword) {
|
||||
formData.confirmpassword = encrypt.encrypt(formData.confirmpassword)
|
||||
}
|
||||
changePassword(formData).then((res) => {
|
||||
if (res.success) {
|
||||
this.$message.success(res.message)
|
||||
this.$emit('ok')
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
this.confirmLoading = false
|
||||
this.close()
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
handleCancel () {
|
||||
|
||||
Reference in New Issue
Block a user