调整验证

main
masong 2 years ago
parent 2a163e13b9
commit ca4d1256b2
  1. 24
      cjy-module-system/cjy-module-system-biz/src/main/java/com/cjy/traceability/module/system/controller/admin/auth/AuthController.java

@ -173,6 +173,11 @@ public class AuthController {
return success(authService.socialLogin(reqVO));
}
/**
* 发送验证码
* @param reqVO
* @return
*/
@PostMapping("/sendRandomCode")
@PermitAll
@Idempotent(timeout = 60, timeUnit = TimeUnit.SECONDS, message = "已发送请求,60s内请勿重复提交")
@ -182,18 +187,31 @@ public class AuthController {
String msg = authService.sendRandomCode(reqVO);
return success(msg);
}
/**
* 重置密码
* @param reqVO
* @return
* @throws Exception
*/
@PostMapping("/resetPassword")
@PermitAll
@Idempotent(timeout = 5, timeUnit = TimeUnit.SECONDS, message = "已发送请求,5s内请勿重复提交")
@Operation(summary = "忘记密码-重置密码", description = "适合未登录的用户,已忘记密码账户")
@OperateLog(enable = false) // 避免 Post 请求被记录操作日志
public CommonResult<String> resetPassword(@RequestBody @Valid ResetPwdReqVO reqVO) throws Exception {
String userName = stringRedisTemplate.opsForValue().get(reqVO.getCaptchaVerification());
if(StrUtil.isBlank(userName)){
String verification = stringRedisTemplate.opsForValue().get(reqVO.getCaptchaVerification());
if(StrUtil.isBlank(verification)){
ErrorCode errorCode = new ErrorCode(500,"验证码过期");
return error(errorCode);
}
if(!verification.equals(reqVO.getCaptchaVerification())){
ErrorCode errorCode = new ErrorCode(500,"验证码错误");
return error(errorCode);
}
//修改密码
AdminUserDO user = userService.getUserByUsername(userName);
AdminUserDO user = userService.getUserByUsername(verification);
if (user.getStatus().equals(CommonStatusEnum.DISABLE)) {
ErrorCode errorCode = new ErrorCode(500,"该账号已停用");
return error(errorCode);

Loading…
Cancel
Save