Skip to content

Commit ce6bb52

Browse files
committed
fix(registrar): pass registrar session when submitting embedded applications
* 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
1 parent ce519f6 commit ce6bb52

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

perun-registrar-lib/src/main/java/cz/metacentrum/perun/registrar/impl/RegistrarManagerImpl.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,7 @@ private void submitEmbeddedGroupApplications(PerunSession sess, List<Group> grou
19551955
groupApplication.setExtSourceType(app.getExtSourceType());
19561956
groupApplication.setCreatedBy("Automatically generated");
19571957

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

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

0 commit comments

Comments
 (0)