fixed: conflict

This commit is contained in:
none 2023-07-03 17:53:51 +08:00
parent a23155cb27
commit e554c01c7b
3 changed files with 6 additions and 2 deletions

View File

@ -63,7 +63,7 @@ public class LoginController {
String limitKey = "admin-login-limit:" + loginRequest.getEmail();
Long reqCount = rateLimiterService.current(limitKey, 3600L);
if (reqCount > 5) {
Long exp = RedisUtil.ttl(limitKey);
Long exp = RedisUtil.ttlWithoutPrefix(limitKey);
return JsonResponse.error(
String.format("您的账号已被锁定,请%s后重试", exp > 60 ? exp / 60 + "分钟" : exp + ""));
}

View File

@ -65,7 +65,7 @@ public class LoginController {
String limitKey = "login-limit:" + req.getEmail();
Long reqCount = rateLimiterService.current(limitKey, 600L);
if (reqCount >= 10) {
Long exp = RedisUtil.ttl(limitKey);
Long exp = RedisUtil.ttlWithoutPrefix(limitKey);
return JsonResponse.error(
String.format("您的账号已被锁定,请%s后重试", exp > 60 ? exp / 60 + "分钟" : exp + ""));
}

View File

@ -104,6 +104,10 @@ public class RedisUtil {
return redisTemplate.getExpire(key, TimeUnit.SECONDS);
}
public static Long ttlWithoutPrefix(String key) {
return redisTemplate.getExpire(key, TimeUnit.SECONDS);
}
/**
* 根据key获取过期时间
*