Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Commit

Permalink
Merge 1b99dad into 73d01e4
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaisavezi committed Oct 3, 2018
2 parents 73d01e4 + 1b99dad commit 2b590d7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -45,6 +47,18 @@
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.setGlobal = function(bool){
config.domain = bool && "https://recaptcha.net";
};

/**
* Sets the reCaptcha stoken which will be used by default is not specified in a specific directive instance.
Expand Down Expand Up @@ -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()) {
Expand All @@ -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);
}

Expand Down

0 comments on commit 2b590d7

Please sign in to comment.