remove captchas from this endpoint
All checks were successful
Deploy API / deploy (ubuntu-latest, 2.44.0) (push) Successful in 52s

This commit is contained in:
Braydon 2024-09-20 00:11:18 -04:00
parent 48f8253612
commit 562fd568e2
4 changed files with 6 additions and 11 deletions

@ -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());
}
}

@ -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 {

@ -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);
}
}

@ -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;
}