|
@@ -121,10 +121,8 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
outputStream.flush();
|
|
|
outputStream.close();
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 获取jwt
|
|
|
- *
|
|
|
* @param username 用户名
|
|
|
* @param password 密码
|
|
|
* @return jwt
|
|
@@ -149,6 +147,8 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
if (null == captchaObject || StringUtil.isBlank(captchaObject.toString()) || !captchaObject.toString().trim().equalsIgnoreCase(captcha)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "验证码错误");
|
|
|
}
|
|
|
+ //使用MD5对密码进行加密
|
|
|
+ String MD5Password = DigestUtils.md5DigestAsHex(password.getBytes());
|
|
|
QueryWrapper<SysUser> userQueryWrapper = new QueryWrapper<>();
|
|
|
userQueryWrapper.eq("username", username)
|
|
|
.eq("status", StatusEnum.Enable.getKey())
|
|
@@ -158,11 +158,11 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
throw new CommonException(ServiceErrorCode.USER_NOT_FOUND);
|
|
|
}
|
|
|
PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
|
|
- if (!passwordEncoder.matches(password, user.getPassword())) {
|
|
|
+ if (!passwordEncoder.matches(MD5Password, user.getPassword())) {
|
|
|
throw new CommonException(ServiceErrorCode.USER_PASSWORD_ERROR);
|
|
|
}
|
|
|
JWT jwt = authServiceClient.getToken("Basic dWFhLXNlcnZpY2U6MTIzNDU2",
|
|
|
- "password", username, password);
|
|
|
+ "password", username, MD5Password);
|
|
|
if (null == jwt) {
|
|
|
throw new CommonException(ServiceErrorCode.GET_TOKEN_FAIL);
|
|
|
}
|
|
@@ -192,22 +192,22 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
jwtStore.setRefreshToken(jwt.getRefresh_token());
|
|
|
tokenFacade.createToken(jwtStore);
|
|
|
/***
|
|
|
- * 未加密密码复杂度判断
|
|
|
+ * 未经过MD5加密密码复杂度判断
|
|
|
*/
|
|
|
- //获取用户医院id
|
|
|
-// String hospitalID = SysUserUtils.getCurrentHospitalID();
|
|
|
-// Long id = user.getId();
|
|
|
-// QueryWrapper<SysUserHospital> UserHospitalQueryWrapper = new QueryWrapper<>();
|
|
|
-// UserHospitalQueryWrapper
|
|
|
-// .eq("user_id", id)
|
|
|
-// .eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
-// SysUserHospital userHospital = sysUserHospitalFacade.getOne(UserHospitalQueryWrapper, false);
|
|
|
-// Long hospitalId = userHospital.getHospitalId();
|
|
|
-// String idStr = String.valueOf(hospitalId);
|
|
|
-// Boolean passwordRegular = passwordRegular(password,idStr);
|
|
|
-// if(!passwordRegular){
|
|
|
-// data.setPasswordComplexity("密码复杂度过低,请及时修改密码");
|
|
|
-// }
|
|
|
+ // 获取用户医院id
|
|
|
+ // String hospitalID = SysUserUtils.getCurrentHospitalID();
|
|
|
+ Long id = user.getId();
|
|
|
+ QueryWrapper<SysUserHospital> UserHospitalQueryWrapper = new QueryWrapper<>();
|
|
|
+ UserHospitalQueryWrapper
|
|
|
+ .eq("user_id", id)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ SysUserHospital userHospital = sysUserHospitalFacade.getOne(UserHospitalQueryWrapper, false);
|
|
|
+ Long hospitalId = userHospital.getHospitalId();
|
|
|
+ String idStr = String.valueOf(hospitalId);
|
|
|
+ Boolean passwordRegular = passwordRegular(password,idStr);
|
|
|
+ if(!passwordRegular){
|
|
|
+ data.setPasswordComplexity("未修改初始密码,请及时修改密码");
|
|
|
+ }
|
|
|
return data;
|
|
|
}
|
|
|
|
|
@@ -304,17 +304,22 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
* @return 修改密码是否成功
|
|
|
*/
|
|
|
public Boolean modifyPassword(String password, String modifyPassword) {
|
|
|
+ //使用MD5对原密码和新密码进行加密
|
|
|
+ String MD5Password = DigestUtils.md5DigestAsHex(password.getBytes());
|
|
|
+ String MD5ModifyPassword = DigestUtils.md5DigestAsHex(modifyPassword.getBytes());
|
|
|
if (StringUtil.isBlank(password)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "请输入密码");
|
|
|
+ "请输入原密码");
|
|
|
}
|
|
|
if (StringUtil.isBlank(modifyPassword)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
"请输入新密码");
|
|
|
}
|
|
|
- if (password.equals(modifyPassword)) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "原密码和新密码不能相同");
|
|
|
+ //对传入的密码进行格式验证
|
|
|
+ String hospitalID = SysUserUtils.getCurrentHospitalID();
|
|
|
+ Boolean regularBoolean = passwordRegular(modifyPassword,hospitalID);
|
|
|
+ if(!regularBoolean){
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "请输入正确格式的新密码");
|
|
|
}
|
|
|
String userId = SysUserUtils.getCurrentPrincipleID();
|
|
|
SysUser user = this.getOne(new QueryWrapper<SysUser>()
|
|
@@ -326,15 +331,14 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
}
|
|
|
PasswordEncoder passwordEncoder
|
|
|
= PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
|
|
- if (!passwordEncoder.matches(password, user.getPassword())) {
|
|
|
+ if (!passwordEncoder.matches(MD5Password, user.getPassword())) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "原密码错误");
|
|
|
}
|
|
|
-// String hospitalID = SysUserUtils.getCurrentHospitalID();
|
|
|
-// Boolean regularBoolean = passwordRegular(modifyPassword,hospitalID);
|
|
|
-// if(!regularBoolean){
|
|
|
-// throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "请输入正确格式的新密码");
|
|
|
-// }
|
|
|
- String entryPassword = passwordEncoder.encode(modifyPassword);
|
|
|
+ if (password.equals(modifyPassword)) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
|
|
|
+ "原密码和新密码不能相同");
|
|
|
+ }
|
|
|
+ String entryPassword = passwordEncoder.encode(MD5ModifyPassword);
|
|
|
user.setPassword(entryPassword);
|
|
|
user.setGmtModified(DateUtil.now());
|
|
|
user.setModifier(userId);
|
|
@@ -348,14 +352,15 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public Boolean passwordRegular(String password,String hospitalId){
|
|
|
- //获取字点表中存储的正则表达式 "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&])[A-Za-z\\d$@$!%*?&]{8,}"
|
|
|
boolean check=true;
|
|
|
Map<String, Map<String, String>> dictionaryWithKey = sysDictionaryFacade.getDictionaryWithKey();
|
|
|
if(dictionaryWithKey!=null){
|
|
|
Map<String, String> stringStringMap = dictionaryWithKey.get("30");
|
|
|
if(stringStringMap!=null) {
|
|
|
String regular = stringStringMap.get(hospitalId);
|
|
|
- check = password.matches(regular);
|
|
|
+ if(StringUtil.isNotEmpty(regular)) {
|
|
|
+ check = password.matches(regular);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return check;
|