From dedc1668f15cc58fb7ca44ffac02be0f22a8b5b8 Mon Sep 17 00:00:00 2001 From: Mihai Date: Wed, 3 Oct 2018 11:35:22 +0300 Subject: [PATCH 1/3] Update service.js --- src/service.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/service.js b/src/service.js index 36bfbc1..6bef478 100644 --- a/src/service.js +++ b/src/service.js @@ -45,6 +45,20 @@ provider.setTheme = function(theme){ config.theme = theme; }; + + /** + * Sets the reCaptcha domain to enable it to work globally. + * More info here https://developers.google.com/recaptcha/docs/faq + * + * @since 2.5.0 + * @param bool Fixes https://github.com/google/recaptcha/issues/87 by enabling recaptcha globally + * + */ + provider.enableGlobal = function(bool){ + config.domain = bool + ? "https://recaptcha.net" + : "https://www.google.com" ; + }; /** * Sets the reCaptcha stoken which will be used by default is not specified in a specific directive instance. @@ -146,7 +160,7 @@ // Check if grecaptcha.render is not defined already. if (isRenderFunctionAvailable()) { callback(); - } else if ($window.document.querySelector('script[src^="https://www.google.com/recaptcha/api.js"]')) { + } else if ($window.document.querySelector('script[src^="'+config.domain+'/recaptcha/api.js"]')) { // wait for script to be loaded. var intervalWait = $interval(function() { if (isRenderFunctionAvailable()) { @@ -159,7 +173,7 @@ var script = $window.document.createElement('script'); script.async = true; script.defer = true; - script.src = 'https://www.google.com/recaptcha/api.js?onload='+provider.onLoadFunctionName+'&render=explicit'; + script.src = config.domain+'/recaptcha/api.js?onload='+provider.onLoadFunctionName+'&render=explicit'; $document.find('body')[0].appendChild(script); } From 8a0f92fc984f5fd3a1d0a3e4e7de95b5041ce561 Mon Sep 17 00:00:00 2001 From: Mihai Date: Wed, 3 Oct 2018 12:41:26 +0300 Subject: [PATCH 2/3] add feature to use recaptcha globally According to "https://developers.google.com/recaptcha/docs/faq" "Can I use reCAPTCHA globally? Yes, please use "www.recaptcha.net" in your code in circumstances when "www.google.com" is not accessible. First, replace with After that, apply the same to everywhere else that uses "www.google.com/recaptcha/" on your site." --- src/service.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/service.js b/src/service.js index 6bef478..3417dd7 100644 --- a/src/service.js +++ b/src/service.js @@ -15,6 +15,8 @@ var provider = this; var config = {}; provider.onLoadFunctionName = 'vcRecaptchaApiLoaded'; + + config.domain = "https://www.google.com"; /** * Sets the reCaptcha configuration values which will be used by default is not specified in a specific directive instance. @@ -55,9 +57,7 @@ * */ provider.enableGlobal = function(bool){ - config.domain = bool - ? "https://recaptcha.net" - : "https://www.google.com" ; + config.domain = bool && "https://recaptcha.net"; }; /** From 1b99dade9d0066d9a5b91cc3d5aa2d569b933e34 Mon Sep 17 00:00:00 2001 From: Mihai Date: Wed, 3 Oct 2018 12:42:19 +0300 Subject: [PATCH 3/3] Update service.js --- src/service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service.js b/src/service.js index 3417dd7..0503c7b 100644 --- a/src/service.js +++ b/src/service.js @@ -56,7 +56,7 @@ * @param bool Fixes https://github.com/google/recaptcha/issues/87 by enabling recaptcha globally * */ - provider.enableGlobal = function(bool){ + provider.setGlobal = function(bool){ config.domain = bool && "https://recaptcha.net"; };