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