Skip to content

Commit

Permalink
- Fix User Signup (#16667)
Browse files Browse the repository at this point in the history
(cherry picked from commit b4cba8a)
  • Loading branch information
mohityadav766 committed Jun 14, 2024
1 parent 521c4fa commit e48f4c6
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,23 @@ public Response createUser(
// Add the roles on user creation
updateUserRolesIfRequired(user, containerRequestContext);

// TODO do we need to authenticate user is creating himself?
Response createdUser = create(uriInfo, securityContext, user);
Response createdUserRes = null;
try {
createdUserRes = create(uriInfo, securityContext, user);
} catch (EntityNotFoundException ex) {
if (securityContext.getUserPrincipal().getName().equals(create.getName())) {
// User is creating himself on signup ?! :(
User created = addHref(uriInfo, repository.create(uriInfo, user));
createdUserRes = Response.created(created.getHref()).entity(created).build();
}
}

// Send Invite mail to user
sendInviteMailToUserForBasicAuth(uriInfo, user, create);

// Update response to remove auth fields
decryptOrNullify(securityContext, (User) createdUser.getEntity());
return createdUser;
decryptOrNullify(securityContext, (User) createdUserRes.getEntity());
return createdUserRes;
}

private void validateAndAddUserAuthForBasic(User user, CreateUser create) {
Expand Down

0 comments on commit e48f4c6

Please sign in to comment.