Skip to content

Commit

Permalink
fix: update enrolled factors in the user profile present into the exe…
Browse files Browse the repository at this point in the history
…cution context

fixes AM-757

fixes gravitee-io/issues#9161
  • Loading branch information
leleueri committed Oct 18, 2023
1 parent 0c35ad1 commit ccdfacb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ public void onRequest(Request request, Response response, ExecutionContext conte
buildEnrolledFactor(factor, factorProvider, user, value, context)
.flatMap(enrolledFactor -> userService.addFactor(user.getId(), enrolledFactor, new DefaultUser(user)))
.subscribe(
__ -> {
updatedUser -> {
LOGGER.debug("MFA factor with ID [{}] enrolled for user {}", factorId, user.getId());
// update inner context user profile with the new list of factors.
// this is important to avoid losing the factors information on
// user updates in the further policies execution (https://github.com/gravitee-io/issues/issues/9161)
user.setFactors(updatedUser.getFactors());
policyChain.doNext(request, response);
},
error -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public void shouldContinue_nominalCase() throws Exception {

executePolicy(configuration, request, response, executionContext, policyChain);
verify(policyChain, times(1)).doNext(request, response);
verify(user).setFactors(any());
}

private void executePolicy(
Expand Down

0 comments on commit ccdfacb

Please sign in to comment.