From 562fd568e28dc24bc3b6e80430923599c046a14d Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Fri, 20 Sep 2024 00:11:18 -0400 Subject: [PATCH] remove captchas from this endpoint --- .../cc/pulseapp/api/model/user/input/UserExistsInput.java | 8 +------- src/main/java/cc/pulseapp/api/service/AuthService.java | 2 +- src/main/java/cc/pulseapp/api/service/CaptchaService.java | 6 ++++-- src/main/java/cc/pulseapp/api/service/UserService.java | 1 - 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/cc/pulseapp/api/model/user/input/UserExistsInput.java b/src/main/java/cc/pulseapp/api/model/user/input/UserExistsInput.java index 306d5a6..71d978d 100644 --- a/src/main/java/cc/pulseapp/api/model/user/input/UserExistsInput.java +++ b/src/main/java/cc/pulseapp/api/model/user/input/UserExistsInput.java @@ -18,18 +18,12 @@ public final class UserExistsInput { */ private final String email; - /** - * The captcha response token to validate. - */ - private final String captchaResponse; - /** * Check if this input is valid. * * @return whether this input is valid */ public boolean isValid() { - return email != null && (!email.isBlank()) - && captchaResponse != null && (!captchaResponse.isBlank()); + return email != null && (!email.isBlank()); } } \ No newline at end of file diff --git a/src/main/java/cc/pulseapp/api/service/AuthService.java b/src/main/java/cc/pulseapp/api/service/AuthService.java index ddb880f..0b15bbd 100644 --- a/src/main/java/cc/pulseapp/api/service/AuthService.java +++ b/src/main/java/cc/pulseapp/api/service/AuthService.java @@ -140,7 +140,7 @@ public final class AuthService { * Use a TFA pin for a user. * * @param user the user to use TFA for - * @param pin the pin to use + * @param pin the pin to use * @throws BadRequestException if using TFA fails */ public void useTfaPin(@NonNull User user, @NonNull String pin) throws BadRequestException { diff --git a/src/main/java/cc/pulseapp/api/service/CaptchaService.java b/src/main/java/cc/pulseapp/api/service/CaptchaService.java index 299dbef..5b7e1f9 100644 --- a/src/main/java/cc/pulseapp/api/service/CaptchaService.java +++ b/src/main/java/cc/pulseapp/api/service/CaptchaService.java @@ -1,6 +1,5 @@ package cc.pulseapp.api.service; -import cc.pulseapp.api.common.EnvironmentUtils; import cc.pulseapp.api.exception.impl.BadRequestException; import cc.pulseapp.api.model.IGenericResponse; import com.google.gson.JsonObject; @@ -27,6 +26,8 @@ public final class CaptchaService { * @throws BadRequestException if the response is invalid */ public void validateCaptcha(@NonNull String captchaResponse) throws BadRequestException { + System.out.println("captchaResponse = " + captchaResponse); + JsonObject body = new JsonObject(); body.addProperty("secret", secretKey); body.addProperty("response", captchaResponse); @@ -34,7 +35,8 @@ public final class CaptchaService { .header(HttpHeaders.CONTENT_TYPE, "application/json") .body(body) .asJson(); - if (EnvironmentUtils.isProduction() && !response.getBody().getObject().getBoolean("success")) { + System.out.println("response = " + response.getBody().toPrettyString()); + if (/*EnvironmentUtils.isProduction() && */!response.getBody().getObject().getBoolean("success")) { throw new BadRequestException(Error.CAPTCHA_INVALID); } } diff --git a/src/main/java/cc/pulseapp/api/service/UserService.java b/src/main/java/cc/pulseapp/api/service/UserService.java index dd68d63..e5899fc 100644 --- a/src/main/java/cc/pulseapp/api/service/UserService.java +++ b/src/main/java/cc/pulseapp/api/service/UserService.java @@ -123,7 +123,6 @@ public final class UserService { if (input == null || (!input.isValid())) { // Ensure the input was provided throw new BadRequestException(Error.MALFORMED_USER_EXISTS_INPUT); } - captchaService.validateCaptcha(input.getCaptchaResponse()); return StringUtils.isValidEmail(input.getEmail()) && userRepository.findByEmailIgnoreCase(input.getEmail()) != null; }