Skip to content

Commit 95fffe6

Browse files
committed
AC-2642: ReCaptcha validation changes
* changes in validations
1 parent 9746de3 commit 95fffe6

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

ReCaptchaCheckout/view/frontend/requirejs-config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ var config = {
99
mixins: {
1010
'Magento_Checkout/js/model/place-order': {
1111
'Magento_ReCaptchaCheckout/js/model/place-order-mixin': true
12+
},
13+
'Magento_ReCaptchaWebapiUi/js/webapiReCaptchaRegistry': {
14+
'Magento_ReCaptchaCheckout/js/webapiReCaptchaRegistry-mixin': true
1215
}
1316
}
1417
}
1518
};
19+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([], function () {
7+
'use strict';
8+
9+
return function(originalFunction){
10+
/**
11+
* Add a listener to when the ReCaptcha finishes verification
12+
* @param {String} id - ReCaptchaId
13+
* @param {Function} func - Will be called back with the token
14+
*/
15+
originalFunction.addListener = function(id , func) {
16+
this._listeners[id] = func;
17+
}
18+
19+
return originalFunction;
20+
};
21+
22+
});

ReCaptchaWebapiUi/view/frontend/web/js/webapiReCaptchaRegistry.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ define([], function () {
3232
* @param {Function} func - Will be called back with the token
3333
*/
3434
addListener: function (id, func) {
35-
this._listeners[id] = func;
35+
if (this.tokens.hasOwnProperty(id)) {
36+
func(this.tokens[id]);
37+
} else {
38+
this._listeners[id] = func;
39+
}
3640
}
3741
};
3842
});

0 commit comments

Comments
 (0)