|
|
|
@ -183,9 +183,13 @@ public class AuthController { |
|
|
|
|
@Idempotent(timeout = 60, timeUnit = TimeUnit.SECONDS, message = "已发送请求,60s内请勿重复提交") |
|
|
|
|
@Operation(summary = "忘记密码-发送验证码", description = "适合未登录的用户,已忘记密码账户") |
|
|
|
|
@OperateLog(enable = false) // 避免 Post 请求被记录操作日志
|
|
|
|
|
public CommonResult<String> sendRandomCode(@RequestBody @Valid SendRandomCodeReqVO reqVO) { |
|
|
|
|
String msg = authService.sendRandomCode(reqVO); |
|
|
|
|
return success(msg); |
|
|
|
|
public CommonResult<String> sendRandomCode(@RequestBody SendRandomCodeReqVO reqVO) { |
|
|
|
|
if(StrUtil.isBlank(reqVO.getUsername())){ |
|
|
|
|
return error(505,"请输入用户名"); |
|
|
|
|
}else if(reqVO.getUsername().length() <4 || reqVO.getUsername().length()>=20){ |
|
|
|
|
return error(505,"用户名长度为4-20位"); |
|
|
|
|
} |
|
|
|
|
return authService.sendRandomCode(reqVO); |
|
|
|
|
} |
|
|
|
|
@GetMapping("/checkRandomCode") |
|
|
|
|
@PermitAll |
|
|
|
@ -193,10 +197,10 @@ public class AuthController { |
|
|
|
|
public CommonResult<Boolean> checkRandomCode(@RequestParam("username") String userName,@RequestParam("captchaVerification") String captchaVerification){ |
|
|
|
|
String verification = stringRedisTemplate.opsForValue().get(captchaVerification); |
|
|
|
|
if(StrUtil.isBlank(verification)){ |
|
|
|
|
return error(500,"请获取邮箱验证码!"); |
|
|
|
|
return error(505,"请获取邮箱验证码!"); |
|
|
|
|
} |
|
|
|
|
if(!verification.equals(userName)){ |
|
|
|
|
return error(500,"请输入正确的用户名"); |
|
|
|
|
return error(505,"验证码错误,请检查!"); |
|
|
|
|
}else{ |
|
|
|
|
return success(true); |
|
|
|
|
} |
|
|
|
@ -216,13 +220,13 @@ public class AuthController { |
|
|
|
|
public CommonResult<String> resetPassword(@RequestBody @Valid ResetPwdReqVO reqVO) throws Exception { |
|
|
|
|
String verification = stringRedisTemplate.opsForValue().get(reqVO.getCaptchaVerification()); |
|
|
|
|
if(StrUtil.isBlank(verification)){ |
|
|
|
|
ErrorCode errorCode = new ErrorCode(500,"验证码过期"); |
|
|
|
|
ErrorCode errorCode = new ErrorCode(505,"验证码过期"); |
|
|
|
|
return error(errorCode); |
|
|
|
|
} |
|
|
|
|
//修改密码
|
|
|
|
|
AdminUserDO user = userService.getUserByUsername(verification); |
|
|
|
|
if (user.getStatus().equals(CommonStatusEnum.DISABLE)) { |
|
|
|
|
ErrorCode errorCode = new ErrorCode(500,"该账号已停用"); |
|
|
|
|
ErrorCode errorCode = new ErrorCode(505,"该账号已停用"); |
|
|
|
|
return error(errorCode); |
|
|
|
|
} |
|
|
|
|
String plainText = CryptoUtils.decryptByRSA(CryptoUtils.PRIVATE_KEY, reqVO.getPassword()); |
|
|
|
|