Open
Description
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
- Implement captcha feature and make sure it is working
- Disable the captcha in backoffice (Base Commerce -> Base Store -> [select basestore] -> Disable 'Captcha Widget Enabled' toggle
- Register a new user in your app using Spartacus
- 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;
}
Metadata
Metadata
Assignees
Labels
No labels