Просмотр исходного кода

Merge pull request #5115 from overleaf/jpa-recaptcha-detection

[web] form-helpers/captcha: step up detection of loaded recaptcha

GitOrigin-RevId: d9ed3b99277ffcdca68df9f8e0b162faeb363451
Jakob Ackermann 5 лет назад
Родитель
Сommit
317f8fa73f
1 измененных файлов с 8 добавлено и 1 удалено
  1. 8 1
      services/web/frontend/js/features/form-helpers/captcha.js

+ 8 - 1
services/web/frontend/js/features/form-helpers/captcha.js

@@ -4,7 +4,14 @@ let recaptchaId
 const recaptchaCallbacks = []
 const recaptchaCallbacks = []
 
 
 export async function validateCaptchaV2() {
 export async function validateCaptchaV2() {
-  if (typeof grecaptcha === 'undefined') {
+  if (
+    // Detect blocked recaptcha
+    typeof grecaptcha === 'undefined' ||
+    // Detect stubbed recaptcha
+    typeof grecaptcha.render !== 'function' ||
+    typeof grecaptcha.execute !== 'function' ||
+    typeof grecaptcha.reset !== 'function'
+  ) {
     return
     return
   }
   }
   if (recaptchaId === undefined) {
   if (recaptchaId === undefined) {