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

Commit ec0a3d0

Browse files
committed
Add action parameter for v3 execution. See https://developers.google.com/recaptcha/docs/v3#actions
1 parent 73d01e4 commit ec0a3d0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/service.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,13 @@
206206

207207
/**
208208
* Executes the reCaptcha
209+
* @param widgetId
210+
* @param [action] the action for reCAPTCHA v3
209211
*/
210-
execute: function (widgetId) {
212+
execute: function (widgetId, action) {
211213
validateRecaptchaInstance();
212214

213-
recaptcha.execute(widgetId);
215+
recaptcha.execute(widgetId, {action: action});
214216
},
215217

216218
/**

tests/service_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ describe('service', function () {
5757
it('should call execute', function () {
5858
var _widgetId = 123;
5959

60-
driver.service.execute(_widgetId);
60+
driver.service.execute(_widgetId, 'my-action');
6161

62-
expect(grecaptchaMock.execute).toHaveBeenCalledWith(_widgetId);
62+
expect(grecaptchaMock.execute).toHaveBeenCalledWith(_widgetId, {action: 'my-action'});
6363
});
6464

6565
it('should call getResponse', function () {
@@ -163,9 +163,9 @@ describe('service', function () {
163163

164164
var _widgetId = 123;
165165

166-
driver.service.execute(_widgetId);
166+
driver.service.execute(_widgetId, 'my-action');
167167

168-
expect(grecaptchaMock.execute).toHaveBeenCalledWith(_widgetId);
168+
expect(grecaptchaMock.execute).toHaveBeenCalledWith(_widgetId, {action: 'my-action'});
169169
});
170170

171171
it('should not proceed if render function not available in grecaptcha', function () {

0 commit comments

Comments
 (0)