Skip to content

Commit

Permalink
fix(registrar): pass registrar session when submitting embedded appli…
Browse files Browse the repository at this point in the history
…cations

* We passed session of approving person but used methods are relying on the fact, that session is properly related to the person submitting its own application.
* This now fails to submit embedded application for a group if approving person is a member of such group - even if application is related to a different user.
* Usage of internal registrar session should be more appropriate
* Do not check VO LOA membership rules for embedded applications, this is already checked in base applications
* Fixed typo that prevented application form to load in registrar if the application was "EXTENSION" and included embedded groups item
* Original PR by https://github.com/zlamalp
  • Loading branch information
xflord authored and zlamalp committed Nov 7, 2023
1 parent 85c1050 commit 89f70e7
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ private void submitEmbeddedGroupApplications(PerunSession sess, List<Group> grou
groupApplication.setExtSourceType(app.getExtSourceType());
groupApplication.setCreatedBy("Automatically generated");

submitApplication(sess, groupApplication, new ArrayList<>());
submitApplication(registrarSession, groupApplication, new ArrayList<>());
} catch (Exception e) {
log.error("Error submitting embedded application {}", e);
failedGroups.put(group.getId(), e.getMessage());
Expand Down Expand Up @@ -3055,7 +3055,7 @@ public List<ApplicationFormItemWithPrefilledValue> getFormItemsWithPrefilledValu
// If the item has no options for the user to offer (bcs user is already member in all possible options,
// remove it from the form completely
if (StringUtils.isBlank(item.getFormItem().getI18n().get(ApplicationFormItem.EN).getOptions())) {
it.remove();
itemsIt.remove();
}
}

Expand Down Expand Up @@ -3311,8 +3311,11 @@ private void checkDuplicateRegistrationAttempt(PerunSession sess, AppType appTyp
// pass not member and have only approved or rejected apps
}
}
// if false, throws exception with reason for GUI
membersManager.canBeMemberWithReason(sess, vo, user, String.valueOf(extSourceLoa));
// check for embedded applications was already done in original app, this would always fail because of registrar session
if (!AppType.EMBEDDED.equals(appType)) {
// if false, throws exception with reason for GUI
membersManager.canBeMemberWithReason(sess, vo, user, String.valueOf(extSourceLoa));
}
}
// if extension, user != null !!
if (AppType.EXTENSION.equals(appType)) {
Expand Down

0 comments on commit 89f70e7

Please sign in to comment.