mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-26 23:22:44 +08:00
优化登录限制的提示
This commit is contained in:
parent
c987b34b9b
commit
a23155cb27
@ -63,7 +63,9 @@ public class LoginController {
|
||||
String limitKey = "admin-login-limit:" + loginRequest.getEmail();
|
||||
Long reqCount = rateLimiterService.current(limitKey, 3600L);
|
||||
if (reqCount > 5) {
|
||||
return JsonResponse.error("多次账密错误,账号被锁1个小时");
|
||||
Long exp = RedisUtil.ttl(limitKey);
|
||||
return JsonResponse.error(
|
||||
String.format("您的账号已被锁定,请%s后重试", exp > 60 ? exp / 60 + "分钟" : exp + "秒"));
|
||||
}
|
||||
|
||||
String password =
|
||||
|
@ -65,7 +65,9 @@ public class LoginController {
|
||||
String limitKey = "login-limit:" + req.getEmail();
|
||||
Long reqCount = rateLimiterService.current(limitKey, 600L);
|
||||
if (reqCount >= 10) {
|
||||
return JsonResponse.error("多次账密错误,账号被锁10分钟");
|
||||
Long exp = RedisUtil.ttl(limitKey);
|
||||
return JsonResponse.error(
|
||||
String.format("您的账号已被锁定,请%s后重试", exp > 60 ? exp / 60 + "分钟" : exp + "秒"));
|
||||
}
|
||||
|
||||
if (!HelperUtil.MD5(req.getPassword() + user.getSalt()).equals(user.getPassword())) {
|
||||
|
@ -26,12 +26,12 @@ import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
public class BackendAuthServiceImpl implements BackendAuthService {
|
||||
@Autowired
|
||||
private AuthService authService;
|
||||
@Autowired private AuthService authService;
|
||||
|
||||
@Override
|
||||
public String loginUsingId(Integer userId, String loginUrl) {
|
||||
return authService.loginUsingId(100000000 + userId, loginUrl, SystemConstant.JWT_PRV_ADMIN_USER);
|
||||
return authService.loginUsingId(
|
||||
100000000 + userId, loginUrl, SystemConstant.JWT_PRV_ADMIN_USER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user