perf:移除TimedCacheService、TimedCacheHelper,新增TsCacheService,同时实现了内存缓存、Redis缓存
This commit is contained in:
@@ -8,8 +8,8 @@ import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.SmUtil;
|
||||
import cn.hutool.crypto.symmetric.SM4;
|
||||
import com.tiesheng.util.ServletKit;
|
||||
import com.tiesheng.util.TimedCacheHelper;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.service.TsCacheService;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -104,12 +104,12 @@ public class EncryptConfig {
|
||||
String salt = decrypt(encrypted).substring(0, saltSize);
|
||||
String inputEncrypted = passwdCreate(inputPasswd, salt);
|
||||
if (!StrUtil.equals(inputEncrypted, encrypted)) {
|
||||
String clientIp = ServletKit.getClientIP();
|
||||
int num = NumberUtil.parseInt(TimedCacheHelper.getTimedCache().get(clientIp, false));
|
||||
String clientIp = "passwdVerify_" + ServletKit.getClientIP();
|
||||
int num = NumberUtil.parseInt(TsCacheService.of().get(clientIp, -1));
|
||||
if (num > 5) {
|
||||
throw new ApiException("登录失败已达6次,请10分钟后再试");
|
||||
}
|
||||
TimedCacheHelper.getTimedCache().put(clientIp, String.valueOf(num + 1), 10 * 60 * 1000);
|
||||
TsCacheService.of().put(clientIp, String.valueOf(num + 1), 10 * 60 * 1000);
|
||||
throw new ApiException("账号或密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user