Skip to content

Commit

Permalink
Fix #3921: Captcha add sourceUrl property (#3925)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Jan 6, 2023
1 parent 971895a commit 666a10c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
6 changes: 6 additions & 0 deletions components/doc/captcha/apidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ const showResponse = (response) => {
<td>en</td>
<td>Language of the widget.</td>
</tr>
<tr>
<td>sourceUrl</td>
<td>string</td>
<td>https://www.google.com/recaptcha/api.js?render=explicit</td>
<td>Source URL of the Captcha as some countries do not allow Google access.</td>
</tr>
</tbody>
</table>
</div>
Expand Down
13 changes: 7 additions & 6 deletions components/lib/captcha/Captcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const Captcha = React.memo(
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.src = props.sourceUrl;
script.async = true;
script.defer = true;

Expand Down Expand Up @@ -103,12 +103,13 @@ Captcha.displayName = 'Captcha';
Captcha.defaultProps = {
__TYPE: 'Captcha',
id: null,
language: 'en',
onExpire: null,
onResponse: null,
siteKey: null,
theme: 'light',
type: 'image',
size: 'normal',
sourceUrl: 'https://www.google.com/recaptcha/api.js?render=explicit',
tabIndex: 0,
language: 'en',
onResponse: null,
onExpire: null
theme: 'light',
type: 'image'
};
11 changes: 6 additions & 5 deletions components/lib/captcha/captcha.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import * as React from 'react';

export interface CaptchaProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref'> {
children?: React.ReactNode;
language?: string;
onExpire?(): void;
onResponse?(response: any): void;
siteKey?: string;
size?: string;
sourceUrl?: string;
theme?: string;
type?: string;
size?: string;
language?: string;
onResponse?(response: any): void;
onExpire?(): void;
children?: React.ReactNode;
}

export declare class Captcha extends React.Component<CaptchaProps, any> {
Expand Down

0 comments on commit 666a10c

Please sign in to comment.