Allow updating email when email as username is set and edit username disabed

#23438
This commit is contained in:
Pedro Igor
2023-09-22 18:12:35 -03:00
committed by Marek Posolda
parent ddf11ced16
commit 1e4f284e31
5 changed files with 67 additions and 5 deletions
@@ -83,6 +83,12 @@ public abstract class AbstractUserProfileProvider<U extends UserProfileProvider>
return !realm.isRegistrationEmailAsUsername();
}
if (USER_API.equals(c.getContext())) {
if (realm.isRegistrationEmailAsUsername()) {
return false;
}
}
return realm.isEditUsernameAllowed();
}
@@ -114,6 +120,12 @@ public abstract class AbstractUserProfileProvider<U extends UserProfileProvider>
return true;
}
if (USER_API.equals(c.getContext())) {
if (realm.isRegistrationEmailAsUsername()) {
return true;
}
}
if (Profile.isFeatureEnabled(Feature.UPDATE_EMAIL)) {
return !(UPDATE_PROFILE.equals(c.getContext()) || ACCOUNT.equals(c.getContext()));
}
@@ -58,6 +58,11 @@ public class LegacyAttributes extends DefaultAttributes {
if (UserProfileContext.IDP_REVIEW.equals(context)) {
return false;
}
if (UserProfileContext.USER_API.equals(context)) {
if (realm.isRegistrationEmailAsUsername()) {
return false;
}
}
return !realm.isEditUsernameAllowed();
}
@@ -65,7 +70,8 @@ public class LegacyAttributes extends DefaultAttributes {
if (isServiceAccountUser()) {
return false;
}
if (UserProfileContext.IDP_REVIEW.equals(context)) {
if (UserProfileContext.IDP_REVIEW.equals(context)
|| UserProfileContext.USER_API.equals(context)) {
return false;
}
if (realm.isRegistrationEmailAsUsername() && !realm.isEditUsernameAllowed()) {