修改了密码强度规则和默认密码配置,并优化了部分业务逻辑。- 更新了密码正则表达式,简化了密码要求,现在密码必须包含英文、数字和特殊符号,且至少8位。

- 更改了用户初始密码的默认值,提升了系统的安全性。
- 移除了部分未使用的代码和冗余注释,清理了代码库。- 优化了部分服务实现,提高了代码的可读性和维护性。
This commit is contained in:
lijiaqi 2024-08-08 11:24:43 +08:00
parent 0668a642ed
commit b334cd13d1
7 changed files with 18 additions and 27 deletions

View File

@ -66,9 +66,10 @@ public class PasswordUtil {
* @return String * @return String
*/ */
public static String checkp(String pwd) { public static String checkp(String pwd) {
String str = "^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d)(?=.*[!\"#$%&'()*+,-./:;<=>?@[\\\\]^_`{|}~])[A-Za-z\\d !\"#$%&'()*+,-./:;<=>?@[\\\\]^_`{|}~]{10,36}$"; // String str = "^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d)(?=.*[!\"#$%&'()*+,-./:;<=>?@[\\\\]^_`{|}~])[A-Za-z\\d !\"#$%&'()*+,-./:;<=>?@[\\\\]^_`{|}~]{10,36}$";
String str = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~`]).{8,}$";
if (!pwd.matches(str)) { if (!pwd.matches(str)) {
return "密码至少由10位及以上大小写字母、数字及特殊字符等混合、随机组成(至少包括数字、小写字母、大写字母和特殊符号各一个),最长36"; return "密码必须英文+数字+特殊符号至少8";
} else { } else {
return "ok"; return "ok";
} }
@ -118,18 +119,6 @@ public class PasswordUtil {
if (!"ok".equals(check)) { if (!"ok".equals(check)) {
throw new ResultException(check); throw new ResultException(check);
} else if (!"ok".equals(rsThree)) {
throw new ResultException(rsThree);
} else if (!"ok".equals(repeat)) {
throw new ResultException(repeat);
} else if (!"ok".equals(checkBirthday)) {
throw new ResultException(checkBirthday);
} else if (!"ok".equals(check3)) {
throw new ResultException(check3);
} else if (!"ok".equals(checkMobile)) {
throw new ResultException(checkMobile);
} else if (!"ok".equals(checkPhone)) {
throw new ResultException(checkPhone);
} else { } else {
return true; return true;
} }

View File

@ -211,7 +211,7 @@ public class UserDeptServiceImpl implements IUserDeptService {
result.set("deptName", deptName); result.set("deptName", deptName);
String initPassword = ConfigCache.getStr(ConfigCache.USER_INIT_PASSWORD, String initPassword = ConfigCache.getStr(ConfigCache.USER_INIT_PASSWORD,
"888888"); "xslc@2025");
initPassword = PasswordUtil.password(loginUser.getSalt(), initPassword); initPassword = PasswordUtil.password(loginUser.getSalt(), initPassword);
//是否需要强制修改密码 //是否需要强制修改密码

View File

@ -199,7 +199,8 @@ public class WorkFlowController extends BaseController {
@ApiOperation(value = "分页查询自己有关的流程通知") @ApiOperation(value = "分页查询自己有关的流程通知")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "current", value = "当前页", dataType = "Integer"), @ApiImplicitParam(name = "current", value = "当前页", dataType = "Integer"),
@ApiImplicitParam(name = "size", value = "每页条数", dataType = "Integer") @ApiImplicitParam(name = "size", value = "每页条数", dataType = "Integer"),
@ApiImplicitParam(name = "isRead", value = "是否已读 true已读 false未读", dataType = "String")
}) })
@ApiOperationSupport( @ApiOperationSupport(
responses = @DynamicResponseParameters(properties = { responses = @DynamicResponseParameters(properties = {
@ -207,8 +208,8 @@ public class WorkFlowController extends BaseController {
}), }),
order = 9 order = 9
) )
public AjaxResult workFlowNoticePageList() { public AjaxResult workFlowNoticePageList(String isRead) {
return workFlowNoticeService.workFlowNoticePageList(getPage()); return workFlowNoticeService.workFlowNoticePageList(getPage(), "true".equals(isRead) ? Boolean.TRUE : Boolean.FALSE);
} }

View File

@ -69,9 +69,9 @@ public class BudgetWorkFlowService implements IWorkFlowType {
public AjaxResult first(WorkFlow workFlow) { public AjaxResult first(WorkFlow workFlow) {
//是否维修上报角色 //是否维修上报角色
User user = userService.getById(workFlow.getUserId()); User user = userService.getById(workFlow.getUserId());
List<Role> roles = roleService.listByIds(Arrays.asList(user.getRoles().split(","))); // List<Role> roles = roleService.listByIds(Arrays.asList(user.getRoles().split(",")));
List<String> roleNames = roles.stream().map(Role::getName).collect(Collectors.toList()); // List<String> roleNames = roles.stream().map(Role::getName).collect(Collectors.toList());
if (!roleNames.contains("维修上报")) throw new ResultException("您不是维修上报人员"); // if (!roleNames.contains("维修上报")) throw new ResultException("您不是维修上报人员");
Dept dept = deptService.getById(user.getDept()); Dept dept = deptService.getById(user.getDept());
if (ObjUtil.isNull(dept)) throw new ResultException("您没有部门"); if (ObjUtil.isNull(dept)) throw new ResultException("您没有部门");

View File

@ -29,9 +29,10 @@ public class WorkFlowNoticeService extends BaseService<WorkFlowNoticeMapper, Wor
* @param page * @param page
* @return * @return
*/ */
public AjaxResult workFlowNoticePageList(Page page) { public AjaxResult workFlowNoticePageList(Page page,Boolean isRead) {
Page<WorkFlowNotice> pageList = page(page, new QueryWrapper<WorkFlowNotice>().lambda() Page<WorkFlowNotice> pageList = page(page, new QueryWrapper<WorkFlowNotice>().lambda()
.eq(WorkFlowNotice::getUserId, StpUtil.getLoginIdAsString()) .eq(WorkFlowNotice::getUserId, StpUtil.getLoginIdAsString())
.eq(ObjUtil.isNotNull(isRead), WorkFlowNotice::getStatus, isRead)
.orderByDesc(WorkFlowNotice::getCreatedAt) .orderByDesc(WorkFlowNotice::getCreatedAt)
); );
return AjaxResult.ok().data(pageList); return AjaxResult.ok().data(pageList);

View File

@ -226,7 +226,7 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
//是否需要强制修改密码 //是否需要强制修改密码
result.set("need_init_password", password.equals(ConfigCache.getStr(ConfigCache.USER_INIT_PASSWORD, result.set("need_init_password", password.equals(ConfigCache.getStr(ConfigCache.USER_INIT_PASSWORD,
"Siwhnd!@Lc2349#!Rdisabled")) ? true : false); "xslc@2025")) ? true : false);
//权限 //权限
result.set("permissions", loginUser.getPermissions()); result.set("permissions", loginUser.getPermissions());
//电子签名 //电子签名
@ -259,7 +259,7 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
*/ */
@Override @Override
public AjaxResult editPassword(String oldPassword, String newPassword) { public AjaxResult editPassword(String oldPassword, String newPassword) {
if (!PasswordUtil.valid(newPassword)) return AjaxResult.fail("密码必须同时包含大写字母、小写字母、数字和特殊字符并且长度至少为8位,最长24"); if (!PasswordUtil.valid(newPassword)) return AjaxResult.fail("密码必须英文+数字+特殊符号至少8");
String loginId = StpUtil.getLoginIdAsString(); String loginId = StpUtil.getLoginIdAsString();
User user = getById(loginId); User user = getById(loginId);
if (!user.getPassword().equals(PasswordUtil.password(user.getSalt(), oldPassword))) return AjaxResult.fail( if (!user.getPassword().equals(PasswordUtil.password(user.getSalt(), oldPassword))) return AjaxResult.fail(
@ -281,7 +281,7 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
*/ */
@Override @Override
public AjaxResult newPassword(String newPassword) { public AjaxResult newPassword(String newPassword) {
if (!PasswordUtil.valid(newPassword)) return AjaxResult.fail("密码必须同时包含大写字母、小写字母、数字和特殊字符并且长度至少为8位,最长24"); if (!PasswordUtil.valid(newPassword)) return AjaxResult.fail("密码必须英文+数字+特殊符号至少8");
String loginId = StpUtil.getLoginIdAsString(); String loginId = StpUtil.getLoginIdAsString();
String salt = RandomUtil.randomString(6); String salt = RandomUtil.randomString(6);
String password = PasswordUtil.password(salt, newPassword); String password = PasswordUtil.password(salt, newPassword);

View File

@ -66,7 +66,7 @@ public class UserServiceImpl extends BaseService<UserMapper, User> implements IU
if (StrUtil.isNotBlank(message)) return AjaxResult.fail(message); if (StrUtil.isNotBlank(message)) return AjaxResult.fail(message);
User user = BeanUtil.copyProperties(userRequest, User.class); User user = BeanUtil.copyProperties(userRequest, User.class);
user.setPhone(CodecUtils.encrypt(user.getPhone())); user.setPhone(CodecUtils.encrypt(user.getPhone()));
String initPassword = ConfigCache.getStr(ConfigCache.USER_INIT_PASSWORD, "Siwhnd!@Lc2349#!Rdisabled"); String initPassword = ConfigCache.getStr(ConfigCache.USER_INIT_PASSWORD, "xslc@2025");
PasswordUtil.valid(initPassword); PasswordUtil.valid(initPassword);
user.setSalt(RandomUtil.randomString(6)); user.setSalt(RandomUtil.randomString(6));
user.setPassword(PasswordUtil.password(user.getSalt(), initPassword)); user.setPassword(PasswordUtil.password(user.getSalt(), initPassword));
@ -199,7 +199,7 @@ public class UserServiceImpl extends BaseService<UserMapper, User> implements IU
User user = getById(id); User user = getById(id);
if (ObjectUtil.isNull(user)) return AjaxResult.fail("该用户不存在"); if (ObjectUtil.isNull(user)) return AjaxResult.fail("该用户不存在");
String initPassword = ConfigCache.getStr(ConfigCache.USER_INIT_PASSWORD, "Siwhnd!@Lc2349#!Rdisabled"); String initPassword = ConfigCache.getStr(ConfigCache.USER_INIT_PASSWORD, "xslc@2025");
PasswordUtil.valid(initPassword); PasswordUtil.valid(initPassword);
user.setSalt(RandomUtil.randomString(6)); user.setSalt(RandomUtil.randomString(6));
user.setPassword(PasswordUtil.password(user.getSalt(), initPassword)); user.setPassword(PasswordUtil.password(user.getSalt(), initPassword));