validateCaptchaV3.js 576 B

12345678910111213141516171819
  1. define(['base'], function(App) {
  2. return App.factory('validateCaptchaV3', function() {
  3. const grecaptcha = window.grecaptcha
  4. const ExposedSettings = window.ExposedSettings
  5. return function validateCaptchaV3(actionName, callback = () => {}) {
  6. if (!grecaptcha) {
  7. return
  8. }
  9. if (!ExposedSettings || !ExposedSettings.recaptchaSiteKeyV3) {
  10. return
  11. }
  12. grecaptcha.ready(function() {
  13. grecaptcha
  14. .execute(ExposedSettings.recaptchaSiteKeyV3, { action: actionName })
  15. .then(callback)
  16. })
  17. }
  18. })
  19. })