vue-recaptcha icon indicating copy to clipboard operation
vue-recaptcha copied to clipboard

Hiding captcha when navigating with useRouter

Open Aspyryan opened this issue 2 years ago • 5 comments

Description

Captcha v3 popup not disappearing when navigation from page to page.

When I navigate using the router.push. The popup is still visible but not needed anymore. Can I somehow destroy the captcha?

image

Minimal Reproducible Example

https://stackblitz.com/edit/vue-rrrchm?file=src%2Fviews%2FLoginView.vue

System info

System: OS: Windows 11 10.0.22631 CPU: (12) x64 AMD Ryzen 5 7600X 6-Core Processor Memory: 15.25 GB / 31.15 GB Binaries: Node: 16.16.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Chromium (120.0.2210.91) Internet Explorer: 11.0.22621.1 npmPackages: @vitejs/plugin-vue: ^4.5.2 => 4.5.2 vite: ^5.0.10 => 5.0.10 vue-recaptcha: ^3.0.0-alpha.2 => 3.0.0-alpha.2

Aspyryan avatar Dec 26 '23 00:12 Aspyryan

I'm also facing this issue. @Aspyryan did u find some workaround fo this ?

@DanSnow is possible to hide/show the badge ? Something like, when unmounted -> hide(), then mounted -> show()

ricardo17coelho avatar Jan 11 '24 14:01 ricardo17coelho

@DanSnow can u pls answer ?

ricardo17coelho avatar Jan 19 '24 08:01 ricardo17coelho

Please check out here for how to hide it https://stackoverflow.com/questions/44543157/how-to-hide-the-google-invisible-recaptcha-badge

DanSnow avatar Jan 22 '24 16:01 DanSnow

@DanSnow if i set the style globally, it will hide the captcha everywhere.. I need to hide it depeding on the current route 🧐

ricardo17coelho avatar Jan 23 '24 07:01 ricardo17coelho

Ok.. i found an workaround.. but i think that u @DanSnow should add an switch show() / hide() to the composable.

Add global stlye:

.grecaptcha-badge {
  visibility: hidden !important;
}

.grecaptcha-badge-show {
  visibility: visible !important;
}

i have an component where i use everywhere i need the Captcha & there i have:

onMounted(() => {
  const grecaptchaBadgeEl = document.querySelector('.grecaptcha-badge');
  if (grecaptchaBadgeEl) {
    grecaptchaBadgeEl.classList.add('grecaptcha-badge-show');
  }
});

onUnmounted(() => {
  const grecaptchaBadgeEl = document.querySelector('.grecaptcha-badge');
  if (grecaptchaBadgeEl) {
    grecaptchaBadgeEl.classList.remove('grecaptcha-badge-show');
  }
});

ricardo17coelho avatar Jan 23 '24 08:01 ricardo17coelho