validateCaptchaV3.js 543 B

12345678910111213141516171819
  1. import App from '../base'
  2. export default 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. })