fix 修改邮箱授权码为非必填后的bug

This commit is contained in:
lijiarao
2021-12-20 15:55:21 +08:00
parent 3961338803
commit 029813b1d6
@@ -376,12 +376,14 @@ public class SysUserController {
baseCommonService.addLog("编辑用户,用户账号:" + sysUser.getUsername(), CommonConstant.LOG_TYPE_2, CommonConstant.OPERATE_TYPE_3);
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
String email;
String emailPassword;
String emailPassword = user.getEmailPassword();
String phone;
try {
//1:先用私钥解密数据
email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
emailPassword = CommonUtils.decryptBtRsaPriKey(user.getEmailPassword(), rsaPrivateKey);
if (StringUtils.isNotBlank(emailPassword)){
emailPassword = CommonUtils.decryptBtRsaPriKey(emailPassword, rsaPrivateKey);
}
phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
} catch (Exception e) {
throw new JeroBootException("解密失败!",e);
@@ -394,11 +396,13 @@ public class SysUserController {
ValidUtil.validate(user);
//3:把数据加密在放回来
email = PasswordUtil.encrypt(email);
emailPassword = PasswordUtil.encrypt(emailPassword);
phone = PasswordUtil.encrypt(phone);
user.setEmail(email);
user.setEmailPassword(emailPassword);
user.setPhone(phone);
if (StringUtils.isNotBlank(emailPassword)){
emailPassword = PasswordUtil.encrypt(emailPassword);
user.setEmailPassword(emailPassword);
}
if (ADMIN_USER.contains(StringUtils.lowerCase(user.getUsername().trim()))) {
throw new JeroBootException("不可添加用户名为adminroottestadministratorsupervisor的用户");
}
@@ -766,7 +770,9 @@ public class SysUserController {
params.setNeedSave(true);
//导入Excel格式校验,看匹配的字段文本概率
Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), SysUserTemplate.class, params,1.0);
if(!t){
if (t == null){
return Result.error("文件导入失败: 导入数据为空");
} else if(!t){
return Result.error("文件格式有误,请下载模板后上传 ");
}
try {