Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReCaptcha: Allow for custom URL #3921

Closed
harsha-bulusu opened this issue Jan 6, 2023 · 6 comments · Fixed by #3925
Closed

ReCaptcha: Allow for custom URL #3921

harsha-bulusu opened this issue Jan 6, 2023 · 6 comments · Fixed by #3925
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@harsha-bulusu
Copy link

Describe the feature you would like to see added

A feature to use a custom URL for the ReCaptcha component can help using ReCaptcha component where Google services are restricted

Is your feature request related to a problem?

Our application when being used by countries like China is unable to use the ReCaptcha component as the ReCaptcha component uses Google Recaptcha and the country restricts usage of Google services

Describe the solution you'd like

  1. Suggestion to override your method by extending your Component

const addRecaptchaScript = () => {
recaptchaScript.current = null;

        if (!window.grecaptcha) {
            let head = document.head || document.getElementsByTagName('head')[0];
            let script = document.createElement('script');

            script.src = 'https://www.google.com/recaptcha/api.js?render=explicit';
            script.async = true;
            script.defer = true;

            script.onload = () => {
                if (!window.grecaptcha) {
                    // eslint-disable-next-line no-console
                    console.warn('Recaptcha is not loaded');

                    return;
                }

                window.grecaptcha.ready(() => {
                    init();
                });
            };

            recaptchaScript.current = script;

            head.appendChild(recaptchaScript.current);
        }
    };
  1. Passing Custom ReCaptcha URL as a prop to the component

Describe alternatives you have considered

No response

Additional context

No response

@harsha-bulusu harsha-bulusu added Status: Discussion Issue or pull request needs to be discussed by Core Team Type: New Feature Issue contains a new feature or new component request labels Jan 6, 2023
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 6, 2023
@melloware melloware changed the title Component: ReCaptcha ReCaptcha: Allow for custom URL Jan 6, 2023
@melloware melloware removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible Status: Discussion Issue or pull request needs to be discussed by Core Team labels Jan 6, 2023
@melloware
Copy link
Member

So just to be clear you need to change this value correct?

script.src = 'https://www.google.com/recaptcha/api.js?render=explicit';

melloware added a commit to melloware/primereact that referenced this issue Jan 6, 2023
@melloware melloware self-assigned this Jan 6, 2023
@melloware melloware added this to the 8.7.4 milestone Jan 6, 2023
@melloware
Copy link
Member

Please check out my PR.

@harsha-bulusu
Copy link
Author

harsha-bulusu commented Jan 6, 2023 via email

@melloware
Copy link
Member

Fixed for 8.7.4

@harsha-bulusu
Copy link
Author

harsha-bulusu commented Jan 6, 2023 via email

@melloware
Copy link
Member

i don't have a temporary solution for you, you might have to wait until 8.7.4 is released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants