Skip to content

Commit

Permalink
FIO-7421: Adds ReCaptcha error messages to the translations config
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandraRamanenka committed Feb 7, 2024
1 parent c73cfd7 commit d5853ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/recaptcha/ReCaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ export default class ReCaptchaComponent extends Component {

const componentData = row[this.component.key];
if (!componentData || !componentData.token) {
this.setCustomValidity('ReCAPTCHA: Token is not specified in submission');
this.setCustomValidity(this.t('reCaptchaTokenNotSpecifiedError'));
return Promise.resolve(false);
}

if (!componentData.success) {
this.setCustomValidity('ReCAPTCHA: Token validation error');
this.setCustomValidity(this.t('reCaptchaTokenValidationError'));
return Promise.resolve(false);
}

return this.hook('validateReCaptcha', componentData.token, () => Promise.resolve(true))
.then((success) => success)
.catch((err) => {
this.setCustomValidity(err.message || err);
this.setCustomValidity(this.t(err.message || err));
return false;
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/translations/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@ export default {
previousButtonAriaLabel:'Previous button. Click to go back to the previous tab',
nextButtonAriaLabel:'Next button. Click to go to the next tab',
submitButtonAriaLabel:'Submit Form button. Click to submit the form',
reCaptchaTokenValidationError: 'ReCAPTCHA: Token validation error',
reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission',
};

0 comments on commit d5853ea

Please sign in to comment.