Email visible on registration page when edit username is not allowed
Closes #17439
This commit is contained in:
parent
ff27f6c77c
commit
48082d08ec
3 changed files with 21 additions and 1 deletions
|
@ -125,7 +125,7 @@ public abstract class AbstractUserProfileProvider<U extends UserProfileProvider>
|
|||
RealmModel realm = c.getSession().getContext().getRealm();
|
||||
|
||||
if (realm.isRegistrationEmailAsUsername() && !realm.isEditUsernameAllowed()) {
|
||||
return false;
|
||||
return REGISTRATION_PROFILE.equals(c.getContext());
|
||||
}
|
||||
|
||||
return !Profile.isFeatureEnabled(Profile.Feature.UPDATE_EMAIL) || c.getContext() != UPDATE_PROFILE;
|
||||
|
|
|
@ -84,6 +84,11 @@ public class RealmAttributeUpdater extends ServerResourceUpdater<RealmAttributeU
|
|||
return this;
|
||||
}
|
||||
|
||||
public RealmAttributeUpdater setEditUserNameAllowed(Boolean value) {
|
||||
rep.setEditUsernameAllowed(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RealmAttributeUpdater setDuplicateEmailsAllowed(Boolean value) {
|
||||
rep.setDuplicateEmailsAllowed(value);
|
||||
return this;
|
||||
|
|
|
@ -613,6 +613,21 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmailAsUsernameWhenEditUserNameDisabled() throws IOException {
|
||||
try (RealmAttributeUpdater rau = configureRealmRegistrationEmailAsUsername(true)
|
||||
.setEditUserNameAllowed(false)
|
||||
.update()) {
|
||||
loginPage.open();
|
||||
loginPage.clickRegister();
|
||||
registerPage.assertCurrent();
|
||||
|
||||
registerPage.registerWithEmailAsUsername("firstName", "lastName", "alice@email", "password", "password");
|
||||
|
||||
assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerWithLoginHint() throws IOException {
|
||||
|
||||
|
|
Loading…
Reference in a new issue