angular-recaptcha icon indicating copy to clipboard operation
angular-recaptcha copied to clipboard

Widget-ID is always 0

Open drakanor opened this issue 8 years ago • 8 comments

The widget ID delivered through on-create is always 0 in my case. My ReCaptcha key is valid, I'm using it on a plain HTML page as well.

<div class="g-recaptcha" vc-recaptcha key="'[mykey]'" ng-model="formData.gRecaptchaResponse" on-create="setWidgetId(widgetId)" on-success="setResponse(response)" on-expire="cbExpiration()"> </div>

$scope.setWidgetId = function (widgetId) { console.log("widgetId: " + widgetId); $scope.recaptchaWidgetId = widgetId; };

console output: widgetId: 0

It was working like that for a while but with current AngularJS 1.6.3 and angular-recaptcha it doesn't work anymore for me when used like shown above.

drakanor avatar Apr 07 '17 12:04 drakanor

0 is valid, that means it is working. If you got null, undefined, an object, a string, or literally anything that isn't a number/integer, then that would be a problem. widget ids comes from recaptcha itself, and are integers, starting at 0. For each instance you create, the number will go up.

TheSharpieOne avatar Apr 07 '17 13:04 TheSharpieOne

Ah, ok. Then there must be another problem with my implementation, because I get the following error when trying to invoke reload() on the widget with id 0:

Error: Invalid ReCAPTCHA client id: 0

` angular .module('ffRecaptcha', ['vcRecaptcha']) .controller('FFRecaptchaController', ['$scope', 'vcRecaptchaService', function($scope, vcRecaptchaService) { $scope.recaptchaWidgetId = null; $scope.recaptchaResponse = null;

    $scope.reloadRecaptcha = function() {
        $scope.recaptchaResponse = null;
        vcRecaptchaService.reload($scope.recaptchaWidgetId);
    };

    $scope.setWidgetId = function (widgetId) {
        $scope.recaptchaWidgetId = widgetId;
    };

    ......
}]);

`

drakanor avatar Apr 07 '17 13:04 drakanor

I'm running into this as well with version 4.1.0. The widget it is being set to zero, but a subsequently attempt to reset it fails, claiming that the identifier is invalid. If I change my dependency on angular-recaptcha back to 4.0.3 then the problem goes away and the reCaptcha gets reset correctly. Is there an API change between these versions that I need to take account of?

davidbryant avatar Apr 30 '17 23:04 davidbryant

Yep, not working for me either. It's always 0

Ponjimon avatar May 03 '17 10:05 Ponjimon

I also run into this problem, using build:2017-04-24 (it wouldn´t hurt to have the version number in the js-file).

AndersBillLinden avatar May 05 '17 11:05 AndersBillLinden

Going back to build:2015-06-22 solves the problem. Then I can use

<div on-create="set_captcha_widget_id(widgetId)"
  vc-recaptcha key="'xyxyxyxyxyxy"
  ng-model="captcha_response">

and in set_captcha_widget, I save the id to be used when I want to vcRecaptchaService.reload(id).

AndersBillLinden avatar May 05 '17 11:05 AndersBillLinden

+1 Error: Invalid ReCAPTCHA client id: 0

alexey-sh avatar Jul 25 '17 21:07 alexey-sh

Do we need to pass the client ID?

I see similar issue: Error: Invalid ReCAPTCHA client id: 0 I have only 1 reCaptcha in the view, so if I just reload without a client ID: vcRecaptchaService.reload(); reCaptch is reset and forces the user to answer the captch again.

Any issues if I don't pass a client ID?

fd98279 avatar Aug 01 '17 11:08 fd98279