fix(auth): handle missing geo region during login

This commit is contained in:
hy001 2026-07-20 17:28:21 +08:00
parent 474daa7070
commit 246b5afeab

View File

@ -273,7 +273,12 @@ public class LoginAccessValidationService {
}
String country = dataObject.getString("country");
String region = dataObject.getString("region");
return BLOCKED_COUNTRY_NAMES.contains(country) || BLOCKED_COUNTRY_NAMES.contains(region);
return isBlockedCountryName(country) || isBlockedCountryName(region);
}
private static boolean isBlockedCountryName(String value) {
// 第三方 IP 定位可能缺少 country/region先过滤空值避免 List.of().contains(null) 抛异常
return StringUtils.isNotBlank(value) && BLOCKED_COUNTRY_NAMES.contains(value.trim());
}
private static JSONObject normalizeIpNcGy(String provider, JSONObject jsonObject) {