fix: allow profile save when country is locked

This commit is contained in:
zhx 2026-07-19 20:27:59 +08:00
parent fa2ab4f3d6
commit a5e85e8b71

View File

@ -141,18 +141,20 @@ public class UpdateUserProfileCmdExe {
return null;
}
// 旧版 App 保存头像等资料时会始终携带 countryId身份锁定用户不能修改国家
// 但不能因此阻断头像昵称等无关字段保存所以仅忽略本次国家字段
if (userIdentityService.hasCountryLockedIdentity(userProfile.getId())) {
log.warn("ignore locked user country change while updating profile userId={}, currentCountryId={}, requestedCountryId={}",
userProfile.getId(), userProfile.getCountryId(), cmd.getCountryId());
return null;
}
Map<Long, SysCountryCode> countryMap = sysCountryCodeService.mapByIdes(Set.of(cmd.getCountryId()));
SysCountryCode country = countryMap.get(cmd.getCountryId());
ResponseAssert.notNull(UserErrorCode.SYS_REGION_NOT_EXIST_ERROR, country);
assertAllowCountryChange(userProfile.getId());
return country;
}
private void assertAllowCountryChange(Long userId) {
ResponseAssert.isFalse(UserErrorCode.USER_COUNTRY_UPDATE_NOT_ALLOWED,
userIdentityService.hasCountryLockedIdentity(userId));
}
private void syncRoomCountry(Long userId, SysCountryCode country) {
userProfileGateway.removeCacheAll(userId);
String regionCode = userRegionGateway.getRegionCode(userId);