mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
af76768eb7
[web] Add recaptcha to add-email GitOrigin-RevId: 0540e0dbc3103dcaac87dd7fabeedbc5892c371c
27 lines
665 B
TypeScript
27 lines
665 B
TypeScript
import { forwardRef } from 'react'
|
|
import ReCAPTCHA from 'react-google-recaptcha'
|
|
|
|
const siteKey = window.ExposedSettings.recaptchaSiteKey
|
|
const recaptchaDisabled = window.ExposedSettings.recaptchaDisabled
|
|
type Page = keyof typeof recaptchaDisabled
|
|
|
|
export const ReCaptcha2 = forwardRef<
|
|
ReCAPTCHA,
|
|
{ page: Page; onChange?: (token: string | null) => void }
|
|
>(function ReCaptcha2({ page: site, onChange }, ref) {
|
|
if (!siteKey) {
|
|
return null
|
|
}
|
|
if (site && recaptchaDisabled[site]) {
|
|
return null
|
|
}
|
|
return (
|
|
<ReCAPTCHA
|
|
ref={ref}
|
|
size="invisible"
|
|
sitekey={siteKey}
|
|
onChange={onChange}
|
|
badge="inline"
|
|
/>
|
|
)
|
|
})
|