diff --git a/financial-services-accelerator/internal-webapps/org.wso2.financial.services.accelerator.consent.mgt.endpoint/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/endpoint/api/ConsentAuthorizeEndpoint.java b/financial-services-accelerator/internal-webapps/org.wso2.financial.services.accelerator.consent.mgt.endpoint/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/endpoint/api/ConsentAuthorizeEndpoint.java index da4a25a45..1c35a63ec 100644 --- a/financial-services-accelerator/internal-webapps/org.wso2.financial.services.accelerator.consent.mgt.endpoint/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/endpoint/api/ConsentAuthorizeEndpoint.java +++ b/financial-services-accelerator/internal-webapps/org.wso2.financial.services.accelerator.consent.mgt.endpoint/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/endpoint/api/ConsentAuthorizeEndpoint.java @@ -256,6 +256,13 @@ public Response persist(@Context HttpServletRequest request, @Context HttpServle throws ConsentException, ConsentManagementException, URISyntaxException { ConsentData consentData = ConsentCache.getConsentDataFromCache(sessionDataKey); + + /* + Remove consent data from the cache to prevent multiple calls to the persist endpoint. + This ensures the flow is completed and avoids further updates after a single persistence. + */ + ConsentCache.removeFromCache(sessionDataKey); + URI location; try { if (consentData == null) { diff --git a/financial-services-accelerator/internal-webapps/org.wso2.financial.services.accelerator.consent.mgt.endpoint/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/endpoint/utils/ConsentCache.java b/financial-services-accelerator/internal-webapps/org.wso2.financial.services.accelerator.consent.mgt.endpoint/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/endpoint/utils/ConsentCache.java index dc28a1fbb..7f7e2de8a 100644 --- a/financial-services-accelerator/internal-webapps/org.wso2.financial.services.accelerator.consent.mgt.endpoint/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/endpoint/utils/ConsentCache.java +++ b/financial-services-accelerator/internal-webapps/org.wso2.financial.services.accelerator.consent.mgt.endpoint/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/endpoint/utils/ConsentCache.java @@ -223,4 +223,13 @@ public int setModifiedExpiryMinutes() { return FinancialServicesConfigParser.getInstance().getCommonCacheModifiedExpiryTime(); } + + /** + * Remove from the consent cache + * @param cacheKey Cache key + */ + public static void removeFromCache(String cacheKey) { + + ConsentCache.getInstance().removeFromCache(ConsentCacheKey.of(cacheKey)); + } }