From 85f7d5e05685455afe103fe0eb8a7e0632410718 Mon Sep 17 00:00:00 2001 From: Beppe Catanese Date: Fri, 1 Dec 2023 11:58:22 +0100 Subject: [PATCH 1/2] Get hostname from frontend --- react-app/src/dashboard/Dashboard.js | 2 +- .../com/adyen/controller/DashboardController.java | 6 +++--- .../com/adyen/model/OnboardingLinkProperties.java | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/adyen/model/OnboardingLinkProperties.java diff --git a/react-app/src/dashboard/Dashboard.js b/react-app/src/dashboard/Dashboard.js index 10c1763..da70627 100644 --- a/react-app/src/dashboard/Dashboard.js +++ b/react-app/src/dashboard/Dashboard.js @@ -34,7 +34,7 @@ export default function Dashboard() { }, []); const generateOnboardingLink = () => { - axios.post('/api/dashboard/getOnboardingLink') + axios.post('/api/dashboard/getOnboardingLink', {host: window.location.origin}) .then((response) => { window.location.href = response.data; }) diff --git a/src/main/java/com/adyen/controller/DashboardController.java b/src/main/java/com/adyen/controller/DashboardController.java index c16afb4..3f128f8 100644 --- a/src/main/java/com/adyen/controller/DashboardController.java +++ b/src/main/java/com/adyen/controller/DashboardController.java @@ -1,5 +1,6 @@ package com.adyen.controller; +import com.adyen.model.OnboardingLinkProperties; import com.adyen.model.User; import com.adyen.model.balanceplatform.AccountHolder; import com.adyen.model.legalentitymanagement.LegalEntity; @@ -7,7 +8,6 @@ import com.adyen.service.ConfigurationAPIService; import com.adyen.service.LegalEntityManagementAPIService; import com.adyen.util.LegalEntityHandler; -import jakarta.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -62,7 +62,7 @@ ResponseEntity getUser() { } @PostMapping("/getOnboardingLink") - ResponseEntity getOnboardingLink(HttpServletRequest request) { + ResponseEntity getOnboardingLink(@RequestBody OnboardingLinkProperties onboardingLinkProperties) { String legalEntityId; @@ -72,7 +72,7 @@ ResponseEntity getOnboardingLink(HttpServletRequest request) { } // get host (used to generate the returnUrl) - String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); + String host = onboardingLinkProperties.getHost(); Optional accountHolder = getConfigurationAPIService().getAccountHolder(getUserIdOnSession()); diff --git a/src/main/java/com/adyen/model/OnboardingLinkProperties.java b/src/main/java/com/adyen/model/OnboardingLinkProperties.java new file mode 100644 index 0000000..f17a7d4 --- /dev/null +++ b/src/main/java/com/adyen/model/OnboardingLinkProperties.java @@ -0,0 +1,14 @@ +package com.adyen.model; + +public class OnboardingLinkProperties { + + private String host; + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } +} From 2b79323f75ba49d081b031f1379434953ac74e13 Mon Sep 17 00:00:00 2001 From: Beppe Catanese Date: Fri, 1 Dec 2023 12:04:38 +0100 Subject: [PATCH 2/2] Format payload --- react-app/src/dashboard/Dashboard.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/react-app/src/dashboard/Dashboard.js b/react-app/src/dashboard/Dashboard.js index da70627..5ab76d1 100644 --- a/react-app/src/dashboard/Dashboard.js +++ b/react-app/src/dashboard/Dashboard.js @@ -34,7 +34,9 @@ export default function Dashboard() { }, []); const generateOnboardingLink = () => { - axios.post('/api/dashboard/getOnboardingLink', {host: window.location.origin}) + axios.post('/api/dashboard/getOnboardingLink', { + host: window.location.origin + }) .then((response) => { window.location.href = response.data; })