Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Captcha feature enable/disable is ignored and captcha header is always sent #19655

Open
sherrerohb opened this issue Nov 28, 2024 · 0 comments
Open

Comments

@sherrerohb
Copy link

Describe the bug
Captcha feature enable/disable is ignored and captcha header is always sent

Tell us the version of Spartacus
2211.28 (also happens on latest)

To Reproduce

  1. Implement captcha feature and make sure it is working
  2. Disable the captcha in backoffice (Base Commerce -> Base Store -> [select basestore] -> Disable 'Captcha Widget Enabled' toggle
  3. Register a new user in your app using Spartacus
  4. Check 'users' HTML request. sap-commerce-cloud-captcha-token header is still present

Expected behavior
sap-commerce-cloud-captcha-token header should only be sent if the 'Captcha Widget Enabled' toggle is enabled.

Desktop:

  • OS: Windows 11
  • Browser Chrome 131.0.6778.86

Explanation and Solution
OccUserProfileAdapter.appendCaptchaToken() creates a const isCaptchaEnabled to decide if the header should be sent. isCaptchaEnabled is a Subscription and will always resolve as truthy:

protected appendCaptchaToken(currentHeaders: HttpHeaders): HttpHeaders {
    if (this.injector && this.captchaConfig?.captchaRenderer) {
      const provider = this.injector.get<CaptchaRenderer>(
        this.captchaConfig.captchaRenderer
      );
      const isCaptchaEnabled = provider
        .getCaptchaConfig()
        .subscribe((config) => {
          return config.enabled;
        });

      if (provider?.getToken() && isCaptchaEnabled) { //isCaptchaEnabled is always truthy
        return currentHeaders.append(USE_CAPTCHA_TOKEN, provider.getToken());
      }
    }
    return currentHeaders;
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant