|
7 | 7 | $config = $block->getCaptchaUiConfig();
|
8 | 8 | $renderingOptions = $config['rendering'] ?? [];
|
9 | 9 | $isInvisible = !empty($config['invisible']);
|
| 10 | +$isBadgeInline = (isset($renderingOptions['badge']) && $renderingOptions['badge']=='inline') ? true : false; |
10 | 11 | ?>
|
11 | 12 | <div class="admin__field <?= /* @noEscape */ $isInvisible ? 'field-invisible-recaptcha' : 'field-recaptcha' ?>">
|
12 | 13 | <div id="admin-recaptcha"
|
@@ -45,12 +46,32 @@ $isInvisible = !empty($config['invisible']);
|
45 | 46 | <?php if ($isInvisible): ?>
|
46 | 47 | $('#login-form').submit(function (event) {
|
47 | 48 | if (!this.token) {
|
| 49 | + <?php if (!$isBadgeInline) : ?> |
48 | 50 | event.preventDefault(event);
|
49 | 51 | event.stopImmediatePropagation();
|
50 | 52 | grecaptcha.execute(this.widgetId);
|
| 53 | + <?php else: ?> |
| 54 | + this.resultSuccessCallback = false; |
| 55 | + let recaptchaResultExecute = grecaptcha.execute(this.widgetId); |
| 56 | + recaptchaResultExecute.then(this.successRecaptchaCallback(), this.failureRecaptchaCallback()); |
| 57 | + if (this.resultSuccessCallback == true) { |
| 58 | + event.preventDefault(event); |
| 59 | + event.stopImmediatePropagation(); |
| 60 | + } |
| 61 | + <?php endif; ?> |
51 | 62 | }
|
52 | 63 | }.bind(this));
|
53 | 64 | <?php endif; ?>
|
| 65 | + |
| 66 | + <?php if ($isInvisible && $isBadgeInline) : ?> |
| 67 | + this.successRecaptchaCallback = function () { |
| 68 | + this.resultSuccessCallback = true; |
| 69 | + }.bind(this); |
| 70 | + |
| 71 | + this.failureRecaptchaCallback = function () { |
| 72 | + }.bind(this); |
| 73 | + <?php endif; ?> |
| 74 | + |
54 | 75 | }.bind(this);
|
55 | 76 |
|
56 | 77 | scriptTag.parentNode.insertBefore(element, scriptTag);
|
|
0 commit comments