captchaElemPrefix interfering with invisible reCaptcha execute call
See original GitHub issueWhen calling the execute method on the InvisibleReCaptchaComponent, I am getting the following error:
ERROR Error: Invalid site key or not loaded in api.js: ngx_captcha_id_ at Object.Qs [as execute] (recaptcha__en.js:formatted:12496) at InvisibleReCaptchaComponent.push../node_modules/ngx-captcha/fesm5/ngx-captcha.js.InvisibleReCaptchaComponent.execute (ngx-captcha.js:637) at LoginComponent.push../src/app/features/login/login.component.ts.LoginComponent.login (login.component.ts:52)
When stepping into the execute call, I see that it is calling…
this.reCaptchaApi.execute(this.captchaElemPrefix);
… which is passing in the “ngx_captcha_id_” value as the “optional widget ID” parameter into the Google API.
Upon stepping into the Google API, its throwing an error while attempting to locate the index of this particular reCaptcha widget within whatever “__grecaptcha_cfg.qd” is; in my tests, “qd” always returns an empty object, which then results in Google throwing the above error; ie:
If I force the “captchaElemPrefix” to be undefined, then the Google API falls back to looking for the first widget, and then everything works properly.
By tossing the following “handleLoad” code in place, I’m able to get past this issue:
handleLoad() {
(<any>this.captchaElem).captchaElemPrefix = undefined;
}
However this feels very hacky… I’m wondering if there is some type of init / setup call that is being missed which would properly populate this “qd” object, such that passing in the widget ID would work?
Also note that this is directly reproducible in the demo app (just downloaded it and tried to hit “execute”, ie:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top GitHub Comments
Thanks a lot for letting me know & great description! It was indeed a bug caused by me during the last refactor. The execute method should be called with
id
that is retrieved from Google when creating new captcha. Fix was as easy as to change the method to:Should be fixed in latest release
3.1.2
. Thanks again!Thank You!
On Fri, Dec 21, 2018 at 8:14 PM Richard Sustek notifications@github.com wrote: