添加密码加密

This commit is contained in:
daihh
2023-08-07 11:56:37 +08:00
parent 90fcc077e7
commit 3eb3d40d59
2 changed files with 38 additions and 3 deletions

View File

@@ -8,6 +8,11 @@ const logout = function() {
return ajax.post('/b1/system/user/logout',{});
}
const getRsaPublicKey(){
return ajax.get('/b1/common/secret/rsa-public-key');
}
/**修改密码
* oldPassword:'',
* newPassword:'',
@@ -20,5 +25,6 @@ const modifyPassword = function(data) {
export default {
logout,
modifyPassword
modifyPassword,
getRsaPublicKey
}

View File

@@ -239,6 +239,7 @@
<script>
import apiTeach from '@/api/modules/teacher.js';
import { mapGetters, mapActions } from 'vuex';
import { JSEncrypt } from 'jsencrypt'
import userApi from "@/api/system/user";
import accountApi from "@/api/account";
import apiPassword from '@/api/boe/login.js'
@@ -538,12 +539,16 @@
this.checkboxGroup = [];
apiUserhobby.info(this.userInfo.aid).then(res=>{
if(res.status == 200) {
let tlist=[];
res.result.forEach(item=>{
this.checkboxGroup.push(item.refId);
item.name = this.sysTypeName(item.refId)
if(item.name){
this.checkboxGroup.push(item.refId);
tlist.push(item);
}
})
// console.log(res.result);
this.interestList = res.result;
this.interestList = tlist;
}
})
},
@@ -685,8 +690,32 @@
})
},
updatePassword(){
let $this=this;
this.$refs.form.validate((valid) => {
if (valid) {
apiPassword.getRsaPublicKey().then(krs=>{
if(krs.code=='0'){
let publicKey=krs.data.list.publickey;
let encryptor = new JSEncrypt();
let rsa ='-----BEGIN PUBLIC KEY-----'+publicKey+'-----END PUBLIC KEY-----';
encryptor.setPublicKey(rsa);
let mpdata={
oldPassword:$this.passwordForm.oldPass,
newPassword:encryptor.encrypt($this.passwordForm.newPass),
confirmPassword:encryptor.encrypt($this.passwordForm.confirmPass)
}
apiUserBasic.modifyPassword(mpdata).then(res=>{
if(res.status==200){
this.$message.success('修改密码成功')
this.dialogVisiblePassword = false;
}else{
this.$message.error(res.message);
}
})
}else{
$this.$message.error('获取公钥错误:'+res.message);
}
})
// apiPassword.modifyPassword({oldPassword:this.passwordForm.oldPass,newPassword:this.passwordForm.newPass,confirmPassword:this.passwordForm.confirmPass}).then(res=>{
// if(res.status==200){
// this.$message.success('修改密码成功')