Commit 762b4e35 authored by honghy's avatar honghy Committed by wux

bug233 短信注册受到攻击问题处理

parent d10b78ea
......@@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.concurrent.TimeUnit;
......@@ -109,8 +108,8 @@ public class AppAuthController {
@ApiOperation(value = "发送手机验证码")
@OperateLog(enable = false) // 避免 Post 请求被记录操作日志
@Idempotent(timeout = 5)
public CommonResult<Boolean> sendSmsCode(@RequestBody @Valid AppAuthSendSmsReqVO reqVO) throws NoSuchAlgorithmException {
public CommonResult<Boolean> sendSmsCode(@RequestBody @Valid AppAuthSendSmsReqVO reqVO) {
// 短信限流
processSmsRequest(reqVO);
authService.sendSmsCode(getLoginUserId(), reqVO);
return success(true);
......@@ -182,7 +181,7 @@ public class AppAuthController {
int attemptsInt = Integer.parseInt(attempts) + 1;
if (attemptsInt > maxAttempts) {
// 如果超过阈值,返回错误信息
throw new ServiceException(500, "The IP address cannot send short messages");
throw new ServiceException(500, "Unlawful request");
} else {
redisHelper.set(redisKey, String.valueOf(attemptsInt), timeWindowSeconds, TimeUnit.DAYS);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment