Skip to content

Commit

Permalink
Merge pull request #348 from JarvusInnovations/develop
Browse files Browse the repository at this point in the history
Release: v1.21.0
  • Loading branch information
themightychris authored Aug 2, 2022
2 parents 793112c + 2400daf commit a71860d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
25 changes: 15 additions & 10 deletions html-templates/contact/contact.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

{if RemoteSystems\ReCaptcha::$siteKey}
<script src='https://www.google.com/recaptcha/api.js'></script>
<script>
function onSubmit(token) {
document.getElementById('contact-form').submit();
}
</script>
{/if}
{/block}

Expand All @@ -15,7 +20,7 @@
<h1 class="header-title title-1">Contact Us</h1>
</header>

<form action="/contact" method="POST" class="contact-form">
<form action="/contact" method="POST" class="contact-form" id="contact-form">
{if $validationErrors}
<div class="notify error">
<strong>Please double-check the fields highlighted below.</strong>
Expand All @@ -32,18 +37,18 @@

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

{if RemoteSystems\ReCaptcha::$siteKey}
<div class="field {tif $validationErrors.ReCaptcha ? 'has-error'}">
<span class="field-label"></span>
<div class="field-control g-recaptcha" data-sitekey="{RemoteSystems\ReCaptcha::$siteKey|escape}"></div>
</div>
{if $validationErrors.ReCaptcha}
<p class="error-text">{$validationErrors.ReCaptcha|escape}</p>
{/if}
{if $validationErrors.ReCaptcha}
<p class="error-text">{$validationErrors.ReCaptcha|escape}</p>
{/if}

<div class="submit-area">
<input type="submit" value="Send">
{if RemoteSystems\ReCaptcha::$siteKey}
<button class="submit g-recaptcha" type="submit" data-sitekey="{RemoteSystems\ReCaptcha::$siteKey|escape}" data-callback='onSubmit' data-action='submit'>
{else}
<button class="submit" type="submit">
{/if}
Send
</button>
</div>

</fieldset>
Expand Down
29 changes: 17 additions & 12 deletions html-templates/register/register.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

{if RemoteSystems\ReCaptcha::$siteKey}
<script src='https://www.google.com/recaptcha/api.js'></script>
<script>
function onSubmit(token) {
document.getElementById('register-form').submit();
}
</script>
{/if}
{/block}

Expand All @@ -20,7 +25,7 @@
<h1 class="header-title title-1">Register a New Account</h1>
</header>

<form method="POST" class="register-form">
<form method="POST" class="register-form" id="register-form">
{if $errors}
<div class="notify error">
<strong>Please double-check the fields highlighted below.</strong>
Expand Down Expand Up @@ -79,18 +84,18 @@
}
</div>

{if RemoteSystems\ReCaptcha::$siteKey}
<div class="field {tif $errors.ReCaptcha ? 'has-error'}">
<span class="field-label"></span>
<div class="field-control g-recaptcha" data-sitekey="{RemoteSystems\ReCaptcha::$siteKey|escape}"></div>
{if $errors.ReCaptcha}
<p class="error-text">{$errors.ReCaptcha|escape}</p>
{/if}
</div>
{/if}

<div class="submit-area">
<button class="submit" type="submit">Create Account</button>
{if $errors.ReCaptcha}
<p class="error-text">{$errors.ReCaptcha|escape}</p>
{/if}

{if RemoteSystems\ReCaptcha::$siteKey}
<button class="submit g-recaptcha" type="submit" data-sitekey="{RemoteSystems\ReCaptcha::$siteKey|escape}" data-callback='onSubmit' data-action='submit'>
{else}
<button class="submit" type="submit">
{/if}
Create Account
</button>
<span class="submit-text">or <a href="/login{tif $.request.return ? cat('?return=', escape($.request.return, url))}">Log In</a></span>
</div>
</fieldset>
Expand Down
2 changes: 2 additions & 0 deletions php-classes/RemoteSystems/ReCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class ReCaptcha
{
public static $siteKey;
public static $secretKey;
public static $scoreThreshold = 0.5;

protected static $instance;

Expand All @@ -18,6 +19,7 @@ public static function getInstance()
{
if (!static::$instance && static::$secretKey) {
static::$instance = new \ReCaptcha\ReCaptcha(static::$secretKey);
static::$instance->setScoreThreshold(static::$scoreThreshold);
}

return static::$instance;
Expand Down

0 comments on commit a71860d

Please sign in to comment.