Catch model exception when creating the admin user
Closes #32356 Signed-off-by: rmartinc <rmartinc@redhat.com>
This commit is contained in:
parent
e1520deb72
commit
f548517f5b
1 changed files with 10 additions and 3 deletions
|
@ -43,6 +43,7 @@ import org.keycloak.cookie.CookieProvider;
|
||||||
import org.keycloak.cookie.CookieType;
|
import org.keycloak.cookie.CookieType;
|
||||||
import org.keycloak.http.HttpRequest;
|
import org.keycloak.http.HttpRequest;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
|
import org.keycloak.models.ModelException;
|
||||||
import org.keycloak.services.ServicesLogger;
|
import org.keycloak.services.ServicesLogger;
|
||||||
import org.keycloak.services.managers.ApplianceBootstrap;
|
import org.keycloak.services.managers.ApplianceBootstrap;
|
||||||
import org.keycloak.services.util.CacheControlUtil;
|
import org.keycloak.services.util.CacheControlUtil;
|
||||||
|
@ -133,10 +134,16 @@ public class WelcomeResource {
|
||||||
return createWelcomePage(null, "Password and confirmation doesn't match");
|
return createWelcomePage(null, "Password and confirmation doesn't match");
|
||||||
}
|
}
|
||||||
|
|
||||||
expireCsrfCookie();
|
try {
|
||||||
|
|
||||||
ApplianceBootstrap applianceBootstrap = new ApplianceBootstrap(session);
|
ApplianceBootstrap applianceBootstrap = new ApplianceBootstrap(session);
|
||||||
applianceBootstrap.createMasterRealmUser(username, password);
|
applianceBootstrap.createMasterRealmUser(username, password);
|
||||||
|
} catch (ModelException e) {
|
||||||
|
session.getTransactionManager().rollback();
|
||||||
|
logger.error("Error creating the administrative user", e);
|
||||||
|
return createWelcomePage(null, "Error creating the administrative user: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
expireCsrfCookie();
|
||||||
|
|
||||||
shouldBootstrap.set(false);
|
shouldBootstrap.set(false);
|
||||||
ServicesLogger.LOGGER.createdTemporaryAdminUser(username);
|
ServicesLogger.LOGGER.createdTemporaryAdminUser(username);
|
||||||
|
|
Loading…
Reference in a new issue