Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Manually clear orphaned recaptcha challenge overlay in android webvie…
Browse files Browse the repository at this point in the history
…ws (#53)

* try manually clear any left over recaptcha overalys

* add alert to debug webview

* disable settings check for netlify build

* Update fix for removing challenge, as g-recaptcha-bubble-arrow is now always shown

* Remove alert for debugging webview

* Put back requirement for config setting and make sure it redirects to welcome if not present.

* Add comment to explain bodge.

* Remove unrelated code
  • Loading branch information
langleyd authored Sep 18, 2024
1 parent 0bbed85 commit 154bf33
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/views/auth/CaptchaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ export default class CaptchaForm extends React.Component<ICaptchaFormProps, ICap

public componentWillUnmount(): void {
this.resetRecaptcha();
// Resettting the captcha does not clear the challenge overlay from the body in android webviews.
// Search for an iframe with the challenge src and remove it's topmost ancestor from the body.
// TODO: Remove this when the "mobile_register" page is retired.
const iframes = document.querySelectorAll("iframe");
for (const iframe of iframes) {
if (iframe.src.includes("https://www.recaptcha.net/recaptcha/api2/bframe")) {
let parentBeforeBody: HTMLElement | null = iframe;
do {
parentBeforeBody = parentBeforeBody.parentElement;
} while (parentBeforeBody?.parentElement && parentBeforeBody.parentElement != document.body);
parentBeforeBody?.remove();
}
}
}

// Borrowed directly from: https://github.com/codeep/react-recaptcha-google/commit/e118fa5670fa268426969323b2e7fe77698376ba
Expand Down

0 comments on commit 154bf33

Please sign in to comment.