remove captchas from this endpoint
All checks were successful
Deploy API / deploy (ubuntu-latest, 2.44.0) (push) Successful in 52s
All checks were successful
Deploy API / deploy (ubuntu-latest, 2.44.0) (push) Successful in 52s
This commit is contained in:
parent
48f8253612
commit
562fd568e2
@ -18,18 +18,12 @@ public final class UserExistsInput {
|
|||||||
*/
|
*/
|
||||||
private final String email;
|
private final String email;
|
||||||
|
|
||||||
/**
|
|
||||||
* The captcha response token to validate.
|
|
||||||
*/
|
|
||||||
private final String captchaResponse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this input is valid.
|
* Check if this input is valid.
|
||||||
*
|
*
|
||||||
* @return whether this input is valid
|
* @return whether this input is valid
|
||||||
*/
|
*/
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return email != null && (!email.isBlank())
|
return email != null && (!email.isBlank());
|
||||||
&& captchaResponse != null && (!captchaResponse.isBlank());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -140,7 +140,7 @@ public final class AuthService {
|
|||||||
* Use a TFA pin for a user.
|
* Use a TFA pin for a user.
|
||||||
*
|
*
|
||||||
* @param user the user to use TFA for
|
* @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
|
* @throws BadRequestException if using TFA fails
|
||||||
*/
|
*/
|
||||||
public void useTfaPin(@NonNull User user, @NonNull String pin) throws BadRequestException {
|
public void useTfaPin(@NonNull User user, @NonNull String pin) throws BadRequestException {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cc.pulseapp.api.service;
|
package cc.pulseapp.api.service;
|
||||||
|
|
||||||
import cc.pulseapp.api.common.EnvironmentUtils;
|
|
||||||
import cc.pulseapp.api.exception.impl.BadRequestException;
|
import cc.pulseapp.api.exception.impl.BadRequestException;
|
||||||
import cc.pulseapp.api.model.IGenericResponse;
|
import cc.pulseapp.api.model.IGenericResponse;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
@ -27,6 +26,8 @@ public final class CaptchaService {
|
|||||||
* @throws BadRequestException if the response is invalid
|
* @throws BadRequestException if the response is invalid
|
||||||
*/
|
*/
|
||||||
public void validateCaptcha(@NonNull String captchaResponse) throws BadRequestException {
|
public void validateCaptcha(@NonNull String captchaResponse) throws BadRequestException {
|
||||||
|
System.out.println("captchaResponse = " + captchaResponse);
|
||||||
|
|
||||||
JsonObject body = new JsonObject();
|
JsonObject body = new JsonObject();
|
||||||
body.addProperty("secret", secretKey);
|
body.addProperty("secret", secretKey);
|
||||||
body.addProperty("response", captchaResponse);
|
body.addProperty("response", captchaResponse);
|
||||||
@ -34,7 +35,8 @@ public final class CaptchaService {
|
|||||||
.header(HttpHeaders.CONTENT_TYPE, "application/json")
|
.header(HttpHeaders.CONTENT_TYPE, "application/json")
|
||||||
.body(body)
|
.body(body)
|
||||||
.asJson();
|
.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);
|
throw new BadRequestException(Error.CAPTCHA_INVALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,6 @@ public final class UserService {
|
|||||||
if (input == null || (!input.isValid())) { // Ensure the input was provided
|
if (input == null || (!input.isValid())) { // Ensure the input was provided
|
||||||
throw new BadRequestException(Error.MALFORMED_USER_EXISTS_INPUT);
|
throw new BadRequestException(Error.MALFORMED_USER_EXISTS_INPUT);
|
||||||
}
|
}
|
||||||
captchaService.validateCaptcha(input.getCaptchaResponse());
|
|
||||||
return StringUtils.isValidEmail(input.getEmail()) && userRepository.findByEmailIgnoreCase(input.getEmail()) != null;
|
return StringUtils.isValidEmail(input.getEmail()) && userRepository.findByEmailIgnoreCase(input.getEmail()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user