Skip to content

Commit

Permalink
Refactoring handle revoke logic for BNR
Browse files Browse the repository at this point in the history
  • Loading branch information
anjuchamantha committed Dec 11, 2024
1 parent e7670fa commit bc8b123
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,12 @@ public void handleRevoke(ConsentAdminData consentAdminData) throws ConsentExcept
final String userID = validateAndGetQueryParam(queryParams, USER_ID);
DetailedConsentResource detailedConsentResource = this.consentCoreService.getDetailedConsent(consentID);
if (detailedConsentResource != null) {
ArrayList<String> userIDs = (ArrayList<String>) consentAdminData.getQueryParams()
.get(CDSConsentExtensionConstants.USER_ID_KEY_NAME);
// userIDs can be null or empty when the request comes from a CustomerCareOfficer
if (userIDs != null && !userIDs.isEmpty()) {
String userId = userIDs.get(0);
if (!canRevokeByBNR(detailedConsentResource, userId)) {
String userId = validateAndGetQueryParam(queryParams,
CDSConsentExtensionConstants.USER_ID_KEY_NAME);
// userId can be null when the request comes from a CustomerCareOfficer
if (userId != null && (!canRevokeByBNR(detailedConsentResource, userId))) {
throw new ConsentException(ResponseStatus.FORBIDDEN,
"User is not authorized to revoke the consent");
}
}
if (StringUtils.isNotBlank(userID) && !isPrimaryUserRevoking(detailedConsentResource, userID)) {
// Deactivate consent mappings as secondary consent holder
Expand Down

0 comments on commit bc8b123

Please sign in to comment.