mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-27 15:42:41 +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();
|
String limitKey = "admin-login-limit:" + loginRequest.getEmail();
|
||||||
Long reqCount = rateLimiterService.current(limitKey, 3600L);
|
Long reqCount = rateLimiterService.current(limitKey, 3600L);
|
||||||
if (reqCount > 5) {
|
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 =
|
String password =
|
||||||
|
@ -65,7 +65,9 @@ public class LoginController {
|
|||||||
String limitKey = "login-limit:" + req.getEmail();
|
String limitKey = "login-limit:" + req.getEmail();
|
||||||
Long reqCount = rateLimiterService.current(limitKey, 600L);
|
Long reqCount = rateLimiterService.current(limitKey, 600L);
|
||||||
if (reqCount >= 10) {
|
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())) {
|
if (!HelperUtil.MD5(req.getPassword() + user.getSalt()).equals(user.getPassword())) {
|
||||||
|
@ -26,12 +26,12 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BackendAuthServiceImpl implements BackendAuthService {
|
public class BackendAuthServiceImpl implements BackendAuthService {
|
||||||
@Autowired
|
@Autowired private AuthService authService;
|
||||||
private AuthService authService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String loginUsingId(Integer userId, String loginUrl) {
|
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
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user