Skip to content

Commit 73156fb

Browse files
feat(recaptcha): upgrade to v3
1 parent 4aac3de commit 73156fb

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

html-templates/contact/contact.tpl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
{if RemoteSystems\ReCaptcha::$siteKey}
99
<script src='https://www.google.com/recaptcha/api.js'></script>
10+
<script>
11+
function onSubmit(token) {
12+
document.getElementById('contact-form').submit();
13+
}
14+
</script>
1015
{/if}
1116
{/block}
1217

@@ -20,7 +25,7 @@
2025

2126
{contentBlock "contact-introduction"}
2227

23-
<form action="/contact" method="POST" class="contact-form">
28+
<form action="/contact" method="POST" class="contact-form" id="contact-form">
2429
{if $validationErrors}
2530
<div class="alert alert-danger">
2631
{_ "Please double-check the fields highlighted below."}
@@ -35,15 +40,17 @@
3540

3641
{textarea inputName=Message label=Message error=$validationErrors.Message required=true}
3742

38-
{if RemoteSystems\ReCaptcha::$siteKey}
39-
<div class="form-group g-recaptcha" data-sitekey="{RemoteSystems\ReCaptcha::$siteKey|escape}"></div>
40-
{/if}
41-
4243
{if $validationErrors.ReCaptcha}
4344
<p class="text-danger">{$validationErrors.ReCaptcha}</p>
4445
{/if}
4546

46-
<button type="submit" class="btn btn-primary">{_ Send}</button>
47+
{if RemoteSystems\ReCaptcha::$siteKey}
48+
<button type="submit" class="btn btn-primary g-recaptcha" data-sitekey="{RemoteSystems\ReCaptcha::$siteKey|escape}" data-callback='onSubmit' data-action='submit'>
49+
{else}
50+
<button type="submit" class="btn btn-primary">
51+
{/if}
52+
{_ "Send"}
53+
</button>
4754
</form>
4855

4956
</div>

html-templates/register/register.tpl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
{if RemoteSystems\ReCaptcha::$siteKey}
99
<script src='https://www.google.com/recaptcha/api.js'></script>
10+
<script>
11+
function onSubmit(token) {
12+
document.getElementById('register').submit();
13+
}
14+
</script>
1015
{/if}
1116
{/block}
1217

@@ -65,12 +70,16 @@
6570
<input type="password" class="form-control" id="PasswordConfirm" name="PasswordConfirm" value="{refill field=PasswordConfirm}">
6671
</div>
6772

68-
{if RemoteSystems\ReCaptcha::$siteKey}
69-
<div class="form-group g-recaptcha" data-sitekey="{RemoteSystems\ReCaptcha::$siteKey|escape}"></div>
70-
{/if}
71-
7273
<div class="form-group">
73-
<p><button type="submit" class="btn btn-primary">{_ "Create Account"}</button></p>
74+
<p>
75+
{if RemoteSystems\ReCaptcha::$siteKey}
76+
<button type="submit" class="btn btn-primary g-recaptcha" data-sitekey="{RemoteSystems\ReCaptcha::$siteKey|escape}" data-callback='onSubmit' data-action='submit'>
77+
{else}
78+
<button type="submit" class="btn btn-primary">
79+
{/if}
80+
{_ "Create Account"}
81+
</button>
82+
</p>
7483
<p class="help-block">{_ "Already have an account?"} <a href="/login{tif $.request.return ? cat('?return=', escape($.request.return, url))}">{_ "Log in"}</a></p>
7584
</div>
7685
{/strip}

0 commit comments

Comments
 (0)