用户新增传输过程加密
This commit is contained in:
@@ -2037,8 +2037,8 @@ CREATE TABLE `sys_user` (
|
|||||||
`avatar` varchar(255) DEFAULT NULL COMMENT '头像',
|
`avatar` varchar(255) DEFAULT NULL COMMENT '头像',
|
||||||
`birthday` datetime DEFAULT NULL COMMENT '生日',
|
`birthday` datetime DEFAULT NULL COMMENT '生日',
|
||||||
`sex` tinyint(1) DEFAULT NULL COMMENT '性别(0-默认未知,1-男,2-女)',
|
`sex` tinyint(1) DEFAULT NULL COMMENT '性别(0-默认未知,1-男,2-女)',
|
||||||
`email` varchar(45) DEFAULT NULL COMMENT '电子邮件',
|
`email` varchar(200) DEFAULT NULL COMMENT '电子邮件',
|
||||||
`phone` varchar(45) DEFAULT NULL COMMENT '电话',
|
`phone` varchar(200) DEFAULT NULL COMMENT '电话',
|
||||||
`org_code` varchar(64) DEFAULT NULL COMMENT '机构编码',
|
`org_code` varchar(64) DEFAULT NULL COMMENT '机构编码',
|
||||||
`status` tinyint(1) DEFAULT NULL COMMENT '性别(1-正常,2-冻结)',
|
`status` tinyint(1) DEFAULT NULL COMMENT '性别(1-正常,2-冻结)',
|
||||||
`del_flag` tinyint(1) DEFAULT NULL COMMENT '删除状态(0-正常,1-已删除)',
|
`del_flag` tinyint(1) DEFAULT NULL COMMENT '删除状态(0-正常,1-已删除)',
|
||||||
|
|||||||
+23
-15
@@ -2,6 +2,7 @@ package com.jero.modules.system.controller;
|
|||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -144,15 +145,17 @@ public class SysUserController {
|
|||||||
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
|
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//1:先用私钥解密数据
|
if (StrUtil.isNotEmpty(user.getEmail())){
|
||||||
String email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
|
String email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
|
||||||
String phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
|
// email = PasswordUtil.encrypt(email);
|
||||||
|
user.setEmail(email);
|
||||||
|
}
|
||||||
|
|
||||||
//3:把数据加密在放回来
|
if (StrUtil.isNotEmpty(user.getPhone())){
|
||||||
email = PasswordUtil.encrypt(email);
|
String phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
|
||||||
phone = PasswordUtil.encrypt(phone);
|
// phone = PasswordUtil.encrypt(phone);
|
||||||
user.setEmail(email);
|
user.setPhone(phone);
|
||||||
user.setPhone(phone);
|
}
|
||||||
|
|
||||||
// 密码加盐
|
// 密码加盐
|
||||||
String password = CommonUtils.decryptBtRsaPriKey(user.getPassword(), rsaPrivateKey);
|
String password = CommonUtils.decryptBtRsaPriKey(user.getPassword(), rsaPrivateKey);
|
||||||
@@ -192,18 +195,23 @@ public class SysUserController {
|
|||||||
result.error500("未找到对应实体");
|
result.error500("未找到对应实体");
|
||||||
}else {
|
}else {
|
||||||
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
|
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
|
||||||
String email;
|
String email = null;
|
||||||
String phone;
|
String phone = null;
|
||||||
try {
|
try {
|
||||||
//1:先用私钥解密数据
|
//1:先用私钥解密数据
|
||||||
email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
|
if (StrUtil.isNotEmpty(user.getEmail())){
|
||||||
phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
|
email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(user.getPhone())){
|
||||||
|
phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new JeroBootException("解密失败!", e);
|
throw new JeroBootException("解密失败!", e);
|
||||||
}
|
}
|
||||||
//3:把数据加密在放回来
|
// 3:把数据加密在放回来
|
||||||
email = PasswordUtil.encrypt(email);
|
// email = PasswordUtil.encrypt(email);
|
||||||
phone = PasswordUtil.encrypt(phone);
|
// phone = PasswordUtil.encrypt(phone);
|
||||||
user.setEmail(email);
|
user.setEmail(email);
|
||||||
user.setPhone(phone);
|
user.setPhone(phone);
|
||||||
user.setUpdateTime(new Date());
|
user.setUpdateTime(new Date());
|
||||||
|
|||||||
+1
@@ -175,4 +175,5 @@ public class SysUser implements Serializable {
|
|||||||
|
|
||||||
/**设备id uniapp推送用*/
|
/**设备id uniapp推送用*/
|
||||||
private String clientId;
|
private String clientId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -35,7 +35,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!--根据parent_id查询下级部门-->
|
<!--根据parent_id查询下级部门-->
|
||||||
<select id="queryTreeListByPid" parameterType="Object" resultType="org.jeecg.modules.system.entity.SysDepart">
|
<select id="queryTreeListByPid" parameterType="Object" resultType="com.jero.modules.system.entity.SysDepart">
|
||||||
SELECT * FROM sys_depart where del_flag = '0'
|
SELECT * FROM sys_depart where del_flag = '0'
|
||||||
<choose>
|
<choose>
|
||||||
<when test="parentId != null and parentId != ''">
|
<when test="parentId != null and parentId != ''">
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 根据OrgCod查询公司信息 -->
|
<!-- 根据OrgCod查询公司信息 -->
|
||||||
<select id="queryCompByOrgCode" resultType="org.jeecg.modules.system.entity.SysDepart">
|
<select id="queryCompByOrgCode" resultType="com.jero.modules.system.entity.SysDepart">
|
||||||
select * from sys_depart where del_flag = '0' and org_category='1' and org_code= #{orgCode,jdbcType=VARCHAR}
|
select * from sys_depart where del_flag = '0' and org_category='1' and org_code= #{orgCode,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -131,7 +131,7 @@ spring:
|
|||||||
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
|
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
|
||||||
datasource:
|
datasource:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://10.0.3.44:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://10.10.10.44:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
|||||||
@@ -71,19 +71,4 @@ export function thirdLogin(token,thirdType) {
|
|||||||
'Content-Type': 'application/json;charset=UTF-8'
|
'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'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
@@ -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
@@ -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: '' },
|
|
||||||
}
|
|
||||||
@@ -134,6 +134,8 @@ import { getAction } from '@/api/manage'
|
|||||||
import { addUser,editUser,queryUserRole,queryall } from '@/api/api'
|
import { addUser,editUser,queryUserRole,queryall } from '@/api/api'
|
||||||
import { disabledAuthFilter } from "@/utils/authFilter"
|
import { disabledAuthFilter } from "@/utils/authFilter"
|
||||||
import { duplicateCheck } from '@/api/api'
|
import { duplicateCheck } from '@/api/api'
|
||||||
|
import { getRSAPublicKey } from '@/utils/encryption.js'
|
||||||
|
import { JSEncrypt } from 'jsencrypt'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "UserModal",
|
name: "UserModal",
|
||||||
@@ -189,6 +191,7 @@ import { duplicateCheck } from '@/api/api'
|
|||||||
tenantsOptions: [],
|
tenantsOptions: [],
|
||||||
rolesOptions:[],
|
rolesOptions:[],
|
||||||
nextDepartOptions:[],
|
nextDepartOptions:[],
|
||||||
|
rsaPublicKey:'',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@@ -196,7 +199,6 @@ import { duplicateCheck } from '@/api/api'
|
|||||||
this.headers = {"X-Access-Token":token}
|
this.headers = {"X-Access-Token":token}
|
||||||
this.initRoleList()
|
this.initRoleList()
|
||||||
this.initTenantList()
|
this.initTenantList()
|
||||||
|
|
||||||
},
|
},
|
||||||
computed:{
|
computed:{
|
||||||
uploadAction:function () {
|
uploadAction:function () {
|
||||||
@@ -324,35 +326,67 @@ import { duplicateCheck } from '@/api/api'
|
|||||||
moment,
|
moment,
|
||||||
handleSubmit () {
|
handleSubmit () {
|
||||||
const that = this;
|
const that = this;
|
||||||
// 触发表单验证
|
//先拉取秘钥
|
||||||
this.$refs.form.validate(valid => {
|
getRSAPublicKey().then(res => {
|
||||||
if (valid) {
|
debugger
|
||||||
that.confirmLoading = true;
|
|
||||||
//如果是上级择传入departIds,否则为空
|
this.rsaPublicKey = res.result
|
||||||
if(this.model.userIdentity!==2){
|
|
||||||
this.model.departIds="";
|
// 触发表单验证
|
||||||
}
|
this.$refs.form.validate(valid => {
|
||||||
let obj;
|
if (valid) {
|
||||||
if(!this.model.id){
|
that.confirmLoading = true;
|
||||||
this.model.id = this.userId;
|
//如果是上级择传入departIds,否则为空
|
||||||
obj=addUser(this.model);
|
if(this.model.userIdentity!==2){
|
||||||
}else{
|
this.model.departIds="";
|
||||||
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();
|
let encrypt = new JSEncrypt();
|
||||||
})
|
encrypt.setPublicKey(that.rsaPublicKey);
|
||||||
}else{
|
|
||||||
return false;
|
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 () {
|
handleCancel () {
|
||||||
@@ -471,12 +505,12 @@ import { duplicateCheck } from '@/api/api'
|
|||||||
this.$refs.departWindow.add(this.checkedDepartKeys,this.userId);
|
this.$refs.departWindow.add(this.checkedDepartKeys,this.userId);
|
||||||
},
|
},
|
||||||
identityChange(e){
|
identityChange(e){
|
||||||
if(e.target.value==="1"){
|
if(e.target.value===1){
|
||||||
this.departIdShow=false;
|
this.departIdShow=false;
|
||||||
}else{
|
}else{
|
||||||
this.departIdShow=true;
|
this.departIdShow=true;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -184,7 +184,7 @@
|
|||||||
import { ACCESS_TOKEN ,ENCRYPTED_STRING} from "@/store/mutation-types"
|
import { ACCESS_TOKEN ,ENCRYPTED_STRING} from "@/store/mutation-types"
|
||||||
import { putAction,postAction,getAction } from '@/api/manage'
|
import { putAction,postAction,getAction } from '@/api/manage'
|
||||||
import { USER_INFO } from "@/store/mutation-types"
|
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
|
const Base64 = require('js-base64').Base64
|
||||||
import {JSEncrypt} from 'jsencrypt'
|
import {JSEncrypt} from 'jsencrypt'
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@
|
|||||||
Vue.ls.remove(ACCESS_TOKEN)
|
Vue.ls.remove(ACCESS_TOKEN)
|
||||||
this.getRouterData();
|
this.getRouterData();
|
||||||
this.handleChangeCheckCode();
|
this.handleChangeCheckCode();
|
||||||
|
this.getPublicKey(); //获取秘钥
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['Login', 'Logout', 'PhoneLogin']),
|
...mapActions(['Login', 'Logout', 'PhoneLogin']),
|
||||||
@@ -323,7 +323,6 @@
|
|||||||
}).catch(()=>{
|
}).catch(()=>{
|
||||||
this.requestCodeSuccess=false
|
this.requestCodeSuccess=false
|
||||||
})
|
})
|
||||||
this.getPublicKey();
|
|
||||||
},
|
},
|
||||||
//获取RSA公钥
|
//获取RSA公钥
|
||||||
getPublicKey(){
|
getPublicKey(){
|
||||||
|
|||||||
Reference in New Issue
Block a user