diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 35a14372164a04b531e2dc722bb98a02b1318234..a3281663531c2f0c1716b8190db48b449045f0ed 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -253,15 +253,18 @@ class AccountController extends Controller { * * @return \OCP\AppFramework\Http\DataResponse */ - public function verifyCaptcha(string $captchaInput = '') : DataResponse { + public function verifyCaptcha(string $captchaInput = '', string $bypassToken = '') : DataResponse { $response = new DataResponse(); - - $captchaResult = (string) $this->session->get(CaptchaService::CAPTCHA_RESULT_KEY, ''); + $captchaToken = $this->config->getSystemValue('bypass_captcha_token', ''); + // Initialize the default status to 400 (Bad Request) $response->setStatus(400); - if ($captchaResult === $captchaInput) { + // Check if the input matches the bypass token or the stored captcha result + $captchaResult = (string) $this->session->get(CaptchaService::CAPTCHA_RESULT_KEY, ''); + if ((!empty($captchaToken) && $bypassToken === $captchaToken) || (!empty($captchaResult) && $captchaInput === $captchaResult)) { $this->session->set(self::CAPTCHA_VERIFIED_CHECK, true); $response->setStatus(200); } + $this->session->remove(CaptchaService::CAPTCHA_RESULT_KEY); return $response; } diff --git a/src/Signup.vue b/src/Signup.vue index d6b2fc4050954fe523e2d15c0f2641839bf24140..82e3158cab96d8ac9729abbb341b7a93fd3e393e 100644 --- a/src/Signup.vue +++ b/src/Signup.vue @@ -3,7 +3,9 @@
- +
diff --git a/src/signup/CaptchaForm.vue b/src/signup/CaptchaForm.vue index 2ad107204115c4d5b2ffd02a2157378980b7877a..5085b8d8a2f71fd01121e08f05a49097db13f026 100644 --- a/src/signup/CaptchaForm.vue +++ b/src/signup/CaptchaForm.vue @@ -85,8 +85,11 @@ export default { this.validation.isCaptchaInputNotMatched = false try { + const urlParams = new URLSearchParams(window.location.search) + const bypassToken = urlParams.get('bypassToken') const data = { captchaInput: this.formData.captchaInput, + bypassToken: bypassToken || null, } const url = generateUrl(`/apps/${this.appName}/accounts/verify_captcha`) await Axios.post(url, data)