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

[IAMRISK-2916] Added support for Auth0 v2 captcha provider #2503

Prev Previous commit
Next Next commit
removed this.renderParams
  • Loading branch information
alexkoumarianos-okta committed Dec 14, 2023
commit 38d1dc2c2d014c275e205579a976e0a7d3825b88
28 changes: 10 additions & 18 deletions src/field/captcha/third_party_captcha.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,41 +124,34 @@ export class ThirdPartyCaptcha extends React.Component {
this.props.onErrored();
});
};
this.renderParams = {
sitekey: this.props.sitekey,
}
}

getRenderParams() {
if (this.props.provider === ARKOSE_PROVIDER) {
// Arkose doesn't use render params
delete this.renderParams;
return;
}


if (this.props.provider === FRIENDLY_CAPTCHA_PROVIDER) {
this.renderParams = {
...this.renderParams,
return {
sitekey: this.props.sitekey,
language: this.props.hl,
doneCallback: this.changeHandler,
errorCallback: this.erroredHandler
};
return;
}
this.renderParams = {
...this.renderParams,
let renderParams = {
sitekey: this.props.sitekey,
callback: this.changeHandler,
'expired-callback': this.expiredHandler,
'error-callback': this.erroredHandler
};

if (this.props.provider === AUTH0_V2_CAPTCHA_PROVIDER) {
this.renderParams = {
...this.renderParams,
renderParams = {
...renderParams,
language: this.props.hl,
theme: 'light'
};
}
return renderParams;
}

injectCaptchaScript(callback = noop) {
Expand Down Expand Up @@ -209,7 +202,6 @@ export class ThirdPartyCaptcha extends React.Component {
}

componentDidMount() {
this.getRenderParams();
this.injectCaptchaScript((arkose) => {
const provider = getCaptchaProvider(this.props.provider);
if (this.props.provider === ARKOSE_PROVIDER) {
Expand All @@ -236,10 +228,10 @@ export class ThirdPartyCaptcha extends React.Component {
}
});
} else if (this.props.provider === FRIENDLY_CAPTCHA_PROVIDER) {
this.widgetInstance = new provider.WidgetInstance(this.ref.current, this.renderParams);
this.widgetInstance = new provider.WidgetInstance(this.ref.current, this.getRenderParams());
} else {
// if this is enterprise then we change this to window.grecaptcha.enterprise.render
this.widgetId = provider.render(this.ref.current, this.renderParams);
this.widgetId = provider.render(this.ref.current, this.getRenderParams());
}
});
}
Expand Down