Skip to content

Commit 74506ae

Browse files
LPD-44395 as used
1 parent 4752d4e commit 74506ae

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

workspaces/liferay-recaptcha-workspace/client-extensions/liferay-recaptcha-etc-spring-boot/src/main/java/com/liferay/recaptcha/RecaptchaValidationRestController.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ public RecaptchaValidationRestController(
4444
public ResponseEntity<String> post(
4545
@AuthenticationPrincipal Jwt jwt, @RequestBody String json) {
4646

47-
JSONObject jsonObject = new JSONObject(json);
47+
JSONObject responseJSONObject = new JSONObject();
4848

4949
MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
5050

51+
JSONObject jsonObject = new JSONObject(json);
52+
5153
body.add("remoteip", jsonObject.getString("remoteip"));
5254
body.add("response", jsonObject.getString("response"));
55+
5356
body.add("secret", _secret);
5457

5558
HttpHeaders httpHeaders = new HttpHeaders();
@@ -63,17 +66,15 @@ public ResponseEntity<String> post(
6366
JSONObject siteVerifyJSONObject = new JSONObject(
6467
responseEntity.getBody());
6568

66-
JSONObject responseJSONObject = new JSONObject();
67-
68-
responseJSONObject.put(
69-
"success", siteVerifyJSONObject.getBoolean("success"));
70-
7169
if (!siteVerifyJSONObject.getBoolean("success")) {
7270
responseJSONObject.put(
7371
"error-codes",
7472
siteVerifyJSONObject.getJSONArray("error-codes"));
7573
}
7674

75+
responseJSONObject.put(
76+
"success", siteVerifyJSONObject.getBoolean("success"));
77+
7778
return new ResponseEntity<>(
7879
responseJSONObject.toString(), HttpStatus.OK);
7980
}

0 commit comments

Comments
 (0)