用户新增传输过程加密

This commit is contained in:
zer0Black
2022-02-24 21:47:08 +08:00
parent 5d221272e4
commit 8749d950f3
11 changed files with 112 additions and 6092 deletions
-15
View File
@@ -71,19 +71,4 @@ export function thirdLogin(token,thirdType) {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}
/**
* 获取RSA公钥
* @returns {*}
*/
export function getRSAPublicKey() {
return axios({
url: `/sys/getRSAPublicKey`,
method: 'get',
timeout: 5000,
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}
+16
View File
@@ -0,0 +1,16 @@
import { axios } from '@/utils/request'
/**
* 获取RSA公钥
* @returns {*}
*/
export function getRSAPublicKey() {
return axios({
url: `/sys/getRSAPublicKey`,
method: 'get',
timeout: 5000,
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}
File diff suppressed because it is too large Load Diff
-20
View File
@@ -1,20 +0,0 @@
/**
* 功能模块
* @type {{LEAVE_EARLY: {text: string, value: string}, LATE: {text: string, value: string}, ABSENT: {text: string, value: string}, NO_SIGN: {text: string, value: string}, NORMAL: {text: string, value: string}}}
*/
export const FunctionEnum = {
EoaCmsBanner: { path: 'modules/eoa/cmsoa/modules/EoaCmsBanner', formData: 'carouselImg' },
EoaCmsNewsInfo: { path: 'modules/eoa/cmsoa/modules/EoaCmsNewsInfo', formData: 'newsInfo' },
EoaCmsRuleInfo: { path: 'modules/eoa/cmsoa/modules/EoaCmsRuleInfo', formData: 'ruleDownInfo' },
EoaCmsSignNews: { path: 'modules/eoa/cmsoa/modules/EoaCmsSignNews', formData: 'signNews' },
EoaCmsUserNotice: { path: 'modules/eoa/cmsoa/modules/EoaCmsUserNotice', formData: 'userNotice' },
EoaCmsPlan: { path: 'modules/eoa/cmsoa/modules/EoaCmsPlan', formData: '' },
EoaCmsLink: { path: 'modules/eoa/cmsoa/modules/EoaCmsLink', formData: '' },
EoaCmsCommUse:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsCommUse', formData: '' },
EoaCmsMyProcess:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsMyProcess', formData: '' },
EoaCmsApplyProcess:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsApplyProcess', formData: '' },
EoaCmsProcessNotice:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsProcessNotice', formData: '' },
EoaCmsProcessChatData:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsProcessChatData', formData: '' },
EoaCmsProcessTypeChat:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsProcessTypeChat', formData: '' },
EoaCmsEmail:{ path: 'modules/eoa/cmsbpm/modules/EoaCmsEmail', formData: '' },
}
+65 -31
View File
@@ -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>
+2 -3
View File
@@ -184,7 +184,7 @@
import { ACCESS_TOKEN ,ENCRYPTED_STRING} from "@/store/mutation-types"
import { putAction,postAction,getAction } from '@/api/manage'
import { USER_INFO } from "@/store/mutation-types"
import {getRSAPublicKey} from '@/api/login.js'
import { getRSAPublicKey } from '@/utils/encryption.js'
const Base64 = require('js-base64').Base64
import {JSEncrypt} from 'jsencrypt'
@@ -225,7 +225,7 @@
Vue.ls.remove(ACCESS_TOKEN)
this.getRouterData();
this.handleChangeCheckCode();
this.getPublicKey(); //获取秘钥
},
methods: {
...mapActions(['Login', 'Logout', 'PhoneLogin']),
@@ -323,7 +323,6 @@
}).catch(()=>{
this.requestCodeSuccess=false
})
this.getPublicKey();
},
//获取RSA公钥
getPublicKey(){