fix: allow profile save when country is locked
This commit is contained in:
parent
fa2ab4f3d6
commit
a5e85e8b71
@ -141,18 +141,20 @@ public class UpdateUserProfileCmdExe {
|
|||||||
return null;
|
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()));
|
Map<Long, SysCountryCode> countryMap = sysCountryCodeService.mapByIdes(Set.of(cmd.getCountryId()));
|
||||||
SysCountryCode country = countryMap.get(cmd.getCountryId());
|
SysCountryCode country = countryMap.get(cmd.getCountryId());
|
||||||
ResponseAssert.notNull(UserErrorCode.SYS_REGION_NOT_EXIST_ERROR, country);
|
ResponseAssert.notNull(UserErrorCode.SYS_REGION_NOT_EXIST_ERROR, country);
|
||||||
assertAllowCountryChange(userProfile.getId());
|
|
||||||
return country;
|
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) {
|
private void syncRoomCountry(Long userId, SysCountryCode country) {
|
||||||
userProfileGateway.removeCacheAll(userId);
|
userProfileGateway.removeCacheAll(userId);
|
||||||
String regionCode = userRegionGateway.getRegionCode(userId);
|
String regionCode = userRegionGateway.getRegionCode(userId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user