This commit is contained in:
Jason 2022-09-16 15:32:24 +08:00
commit 32963b1ab0
2 changed files with 2 additions and 2 deletions

View File

@ -73,13 +73,12 @@ public class UserController {
*/
@PostMapping("/changePwd")
public Object changePwd(@RequestBody Map<String, String> params) {
Assert.notNull(params.get("oldPassword"), "oldPassword参数缺失");
Assert.notNull(params.get("password"), "password参数缺失");
if(!Pattern.matches("^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$", params.get("password"))){
throw new OperateException("密码必须是6-20字母+数字组合!");
}
Integer userId = LikeFrontThreadLocal.getUserId();
iUserService.changePwd(params.get("password"), params.get("oldPassword"), userId);
iUserService.changePwd(params.get("password"), params.getOrDefault("oldPassword", null), userId);
return AjaxResult.success();
}

View File

@ -183,6 +183,7 @@ public class UserServiceImpl implements IUserService {
Assert.notNull(user, "用户不存在");
if (!user.getPassword().equals("")) {
Assert.notNull(oldPassword, "oldPassword参数缺失");
String oldPwd = ToolsUtil.makeMd5(oldPassword.trim() + user.getSalt());
if (!oldPwd.equals(user.getPassword())) {
throw new OperateException("原密码不正确!");