Skip to content

Commit

Permalink
KEYCLOAK-19602 moved create/update admin console event after commit, …
Browse files Browse the repository at this point in the history
…to prevent false alarm to event listeners
  • Loading branch information
Satria Hu authored and abstractj committed Feb 16, 2022
1 parent 43ef7f1 commit 31d8a92
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 188,10 @@ public Response updateUser(final UserRepresentation rep) {
session.getProvider(BruteForceProtector.class).cleanUpPermanentLockout(session, realm, user);
}

adminEvent.operation(OperationType.UPDATE).resourcePath(session.getContext().getUri()).representation(rep).success();

if (session.getTransactionManager().isActive()) {
session.getTransactionManager().commit();
}
adminEvent.operation(OperationType.UPDATE).resourcePath(session.getContext().getUri()).representation(rep).success();
return Response.noContent().build();
} catch (ModelDuplicateException e) {
return ErrorResponse.exists("User exists with same username or email");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 161,11 @@ public Response createUser(final UserRepresentation rep) {
RepresentationToModel.createGroups(rep, realm, user);

RepresentationToModel.createCredentials(rep, session, realm, user, true);
adminEvent.operation(OperationType.CREATE).resourcePath(session.getContext().getUri(), user.getId()).representation(rep).success();

if (session.getTransactionManager().isActive()) {
session.getTransactionManager().commit();
}

adminEvent.operation(OperationType.CREATE).resourcePath(session.getContext().getUri(), user.getId()).representation(rep).success();
return Response.created(session.getContext().getUri().getAbsolutePathBuilder().path(user.getId()).build()).build();
} catch (ModelDuplicateException e) {
if (session.getTransactionManager().isActive()) {
Expand Down

0 comments on commit 31d8a92

Please sign in to comment.