question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recaptcha v3 loads on all pages with a form

See original GitHub issue

Summary

I’m submitting a:

  • bug report
  • feature request
  • question / support request
  • other

Description

I have a problem when try to integrate recaptcha v3 in mi angular app, the problem is when I register the provider, captcha is displayed in all component with a form inside, any one can help me? Really is so weird…

Thanks a lot!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
psenechalcommented, Dec 3, 2019

I did a little research and this may be what is intended with v3 since it looks like it attempts to build a profile of the user’s actions to determine if they’re a bot or not.

I decided the easiest approach was just to hide the badge by default and then unhide it on pages where I want it to display. I accomplished this by adding a global style and a class specific style

// hide recaptcha badge
.grecaptcha-badge {
  visibility: hidden;
}

// only show recaptcha badge on needed pages
body.recaptcha {
  .grecaptcha-badge {
    visibility: visible;
  }
}

on components where I want to display the badge, I add a “recaptcha” class to the body in OnInit and remove it in OnDestroy. I’m using Angular Universal, so I have to check to make sure I’m in the browser

  constructor(
    @Inject(DOCUMENT) private _document: any,
    @Inject(PLATFORM_ID) private _platformId: any,
    private _recaptchaV3Service: ReCaptchaV3Service
  ) { }

  ngOnInit(): void {
    if (isPlatformBrowser(this._platformId)) {
      this._document.body.classList.add('recaptcha');
    }
  }

  ngOnDestroy(): void {
    if (isPlatformBrowser(this._platformId)) {
      this._document.body.classList.remove('recaptcha');
    }
  }

Hope that helps someone.

0reactions
DethArielcommented, Jul 22, 2021

Hey all! I see that you’ve resolved this issue already, but I wanted to call out that this is indeed expected behavior. To help others discover this, I’ve added a small section to the project’s README, which essentially simply points to reCAPTCHA documentation. It is worth noting, however, that if you hide the badge, reCAPTCHA terms of service require you to include the branding visibility in a way that would be perceivable by your users (the FAQ link gives a good example of doing this).

Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recaptcha v3 script is being added to all pages - WordPress.org
We've been using the wpcf7_load_js hooks for years to add Contact Form 7 script ONLY on contact pages, but your integration of Recaptcha...
Read more >
Only Load reCaptcha V3 Scripts On Pages That Have Forms
For speed purposes, I'd like to find a way to ONLY load the Google reCaptcha V3 scripts IF there is a form on...
Read more >
Disable Google reCAPTCHA (v3) for all pages Except the one ...
In this article, we guide you remove Google reCAPTCHA v3 badge on every page with Contact Form 7 version > 5.2.x. To do...
Read more >
is it possible to load reCAPTCHA v3 only on needed Pages
i found guennis thread: — we all only need the Tool on Page with some Form Elements / contact infos or comments. So...
Read more >
Loading reCAPTCHA - Google Developers
All versions of the reCAPTCHA can be loaded asynchronously. Loading reCAPTCHA asynchronously does not impact its ability to identify suspicious ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found