diff --git a/wise-api/src/main/java/com/wisemapping/rest/UserController.java b/wise-api/src/main/java/com/wisemapping/rest/UserController.java index 102374a7..addf5544 100644 --- a/wise-api/src/main/java/com/wisemapping/rest/UserController.java +++ b/wise-api/src/main/java/com/wisemapping/rest/UserController.java @@ -60,8 +60,11 @@ public class UserController extends BaseController { @Autowired private AuthenticationManager authManager; - @Value("${google.recaptcha2.enabled:false}") - private Boolean recatchaEnabled; + @Value("${app.registration.enabled:true}") + private Boolean registrationEnabled; + + @Value("${app.registration.captcha.enabled:true}") + private Boolean registrationCaptchaEnabled; @Value("${app.accounts.exclusion.domain:''}") private String domainBanExclusion; @@ -74,6 +77,9 @@ public class UserController extends BaseController { public void registerUser(@RequestBody RestUserRegistration registration, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws WiseMappingException, BindException { logger.debug("Register new user:" + registration.getEmail()); + if (!registrationEnabled) { + throw new WiseMappingException("Registration is disabled. You can enable it using app.registration.enabled"); + } if (registration.getPassword().length() > Account.MAX_PASSWORD_LENGTH_SIZE) { throw new PasswordTooLongException(); @@ -85,7 +91,6 @@ public class UserController extends BaseController { remoteIp = request.getRemoteAddr(); } logger.debug("Remote address" + remoteIp); - verify(registration, remoteIp); final Account user = new Account(); @@ -120,7 +125,7 @@ public class UserController extends BaseController { validator.validate(registration, errors); // If captcha is enabled, generate it ... - if (recatchaEnabled) { + if (registrationCaptchaEnabled) { final String recaptcha = registration.getRecaptcha(); if (recaptcha != null) { final String reCaptchaResponse = captchaService.verifyRecaptcha(remoteAddress, recaptcha); diff --git a/wise-api/src/main/java/com/wisemapping/service/RecaptchaService.java b/wise-api/src/main/java/com/wisemapping/service/RecaptchaService.java index cfb5d67c..713dcc9a 100644 --- a/wise-api/src/main/java/com/wisemapping/service/RecaptchaService.java +++ b/wise-api/src/main/java/com/wisemapping/service/RecaptchaService.java @@ -47,14 +47,13 @@ public class RecaptchaService { private final static ObjectMapper objectMapper = new ObjectMapper(); public static final String CATCH_ERROR_CODE_TIMEOUT_OR_DUPLICATE = "timeout-or-duplicate"; - public static final String CATCHA_ERROR_CODE_INPUT_RESPONSE = "invalid-input-response"; - @Value("${google.recaptcha2.secretKey}") + @Value("${app.registration.captcha.secretKey:''}") private String recaptchaSecret; @Nullable public String verifyRecaptcha(@NotNull String ip, @NotNull String recaptcha) { - + String result = StringUtils.EMPTY; final List build = Form.form() .add("secret", recaptchaSecret) .add("response", recaptcha) @@ -66,7 +65,6 @@ public class RecaptchaService { logger.debug("Response from recaptchaSecret: " + recaptchaSecret); logger.debug("Response from recaptcha: " + recaptcha); - String result = StringUtils.EMPTY; try { final byte[] body = Request .Post(GOOGLE_RECAPTCHA_VERIFY_URL) @@ -101,8 +99,4 @@ public class RecaptchaService { return result; } - - public void setRecaptchaSecret(String recaptchaSecret) { - this.recaptchaSecret = recaptchaSecret; - } } \ No newline at end of file diff --git a/wise-api/src/main/resources/application.yml b/wise-api/src/main/resources/application.yml index d98339d3..7f098633 100644 --- a/wise-api/src/main/resources/application.yml +++ b/wise-api/src/main/resources/application.yml @@ -86,10 +86,9 @@ app: # accounts: # exclusion: # domain: - -google: - recaptcha2: - enabled: true - secretKey: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe - siteKey: 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI + registration: + enabled: false + captcha: + enabled: false + secretKey: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe diff --git a/wise-api/src/main/resources/mail/baseLayout.vm b/wise-api/src/main/resources/mail/baseLayout.vm index 7b7b6e52..8603a2d0 100644 --- a/wise-api/src/main/resources/mail/baseLayout.vm +++ b/wise-api/src/main/resources/mail/baseLayout.vm @@ -3,7 +3,7 @@
- + - +
@@ -18,7 +18,7 @@ ${messageTitle}