用户新增传输过程加密
This commit is contained in:
@@ -134,6 +134,8 @@ import { getAction } from '@/api/manage'
|
||||
import { addUser,editUser,queryUserRole,queryall } from '@/api/api'
|
||||
import { disabledAuthFilter } from "@/utils/authFilter"
|
||||
import { duplicateCheck } from '@/api/api'
|
||||
import { getRSAPublicKey } from '@/utils/encryption.js'
|
||||
import { JSEncrypt } from 'jsencrypt'
|
||||
|
||||
export default {
|
||||
name: "UserModal",
|
||||
@@ -189,6 +191,7 @@ import { duplicateCheck } from '@/api/api'
|
||||
tenantsOptions: [],
|
||||
rolesOptions:[],
|
||||
nextDepartOptions:[],
|
||||
rsaPublicKey:'',
|
||||
}
|
||||
},
|
||||
created () {
|
||||
@@ -196,7 +199,6 @@ import { duplicateCheck } from '@/api/api'
|
||||
this.headers = {"X-Access-Token":token}
|
||||
this.initRoleList()
|
||||
this.initTenantList()
|
||||
|
||||
},
|
||||
computed:{
|
||||
uploadAction:function () {
|
||||
@@ -324,35 +326,67 @@ import { duplicateCheck } from '@/api/api'
|
||||
moment,
|
||||
handleSubmit () {
|
||||
const that = this;
|
||||
// 触发表单验证
|
||||
this.$refs.form.validate(valid => {
|
||||
if (valid) {
|
||||
that.confirmLoading = true;
|
||||
//如果是上级择传入departIds,否则为空
|
||||
if(this.model.userIdentity!==2){
|
||||
this.model.departIds="";
|
||||
}
|
||||
let obj;
|
||||
if(!this.model.id){
|
||||
this.model.id = this.userId;
|
||||
obj=addUser(this.model);
|
||||
}else{
|
||||
obj=editUser(this.model);
|
||||
}
|
||||
obj.then((res)=>{
|
||||
if(res.success){
|
||||
that.$message.success(res.message);
|
||||
that.$emit('ok');
|
||||
}else{
|
||||
that.$message.warning(res.message);
|
||||
//先拉取秘钥
|
||||
getRSAPublicKey().then(res => {
|
||||
debugger
|
||||
|
||||
this.rsaPublicKey = res.result
|
||||
|
||||
// 触发表单验证
|
||||
this.$refs.form.validate(valid => {
|
||||
if (valid) {
|
||||
that.confirmLoading = true;
|
||||
//如果是上级择传入departIds,否则为空
|
||||
if(this.model.userIdentity!==2){
|
||||
this.model.departIds="";
|
||||
}
|
||||
}).finally(() => {
|
||||
that.confirmLoading = false;
|
||||
that.close();
|
||||
})
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 对密码、邮箱、手机号进行加密
|
||||
let encrypt = new JSEncrypt();
|
||||
encrypt.setPublicKey(that.rsaPublicKey);
|
||||
|
||||
if (this.model.password != ""
|
||||
&& this.model.password != null
|
||||
&& this.model.password != undefined){
|
||||
this.model.password = encrypt.encrypt(this.model.password)
|
||||
}
|
||||
|
||||
if (this.model.phone != ""
|
||||
&& this.model.phone != null
|
||||
&& this.model.phone != undefined){
|
||||
this.model.phone = encrypt.encrypt(this.model.phone)
|
||||
}
|
||||
|
||||
if (this.model.email != ""
|
||||
&& this.model.email != null
|
||||
&& this.model.email != undefined){
|
||||
this.model.email = encrypt.encrypt(this.model.email)
|
||||
}
|
||||
this.model.rsaPublicKey = that.rsaPublicKey
|
||||
|
||||
let obj;
|
||||
if(!this.model.id){
|
||||
this.model.id = this.userId;
|
||||
obj=addUser(this.model);
|
||||
}else{
|
||||
obj=editUser(this.model);
|
||||
}
|
||||
|
||||
obj.then((res)=>{
|
||||
if(res.success){
|
||||
that.$message.success(res.message);
|
||||
that.$emit('ok');
|
||||
}else{
|
||||
that.$message.warning(res.message);
|
||||
}
|
||||
}).finally(() => {
|
||||
that.confirmLoading = false;
|
||||
that.close();
|
||||
})
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
handleCancel () {
|
||||
@@ -471,12 +505,12 @@ import { duplicateCheck } from '@/api/api'
|
||||
this.$refs.departWindow.add(this.checkedDepartKeys,this.userId);
|
||||
},
|
||||
identityChange(e){
|
||||
if(e.target.value==="1"){
|
||||
if(e.target.value===1){
|
||||
this.departIdShow=false;
|
||||
}else{
|
||||
this.departIdShow=true;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user