From 21f64049d0ecfd1b006eee48e4be263dca206bcd Mon Sep 17 00:00:00 2001 From: Ben Croker Date: Fri, 2 Apr 2021 09:56:28 +0200 Subject: [PATCH] Setting tweaks --- src/config.php | 6 +++--- src/models/SettingsModel.php | 4 ++-- src/templates/_settings.html | 26 +++++++++++--------------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/config.php b/src/config.php index d1d0bbe..d572b9d 100755 --- a/src/config.php +++ b/src/config.php @@ -46,12 +46,12 @@ // The template to use if Snaptcha identifies a submission as spam. //'errorTemplate' => '', + // The minimum time for form submission in seconds (increase this to harden spam blocking). + //'minimumSubmitTime' => 1, + // The expiration time for form submissions in minutes. //'expirationTime' => 60, - // The minimum time for form submission in seconds (increase this to harden spam blocking). - //'minimumSubmitTime' => 3, - // The controller actions to exclude from validation. //'excludeControllerActions' => [], diff --git a/src/models/SettingsModel.php b/src/models/SettingsModel.php index 96e562e..92825af 100644 --- a/src/models/SettingsModel.php +++ b/src/models/SettingsModel.php @@ -67,12 +67,12 @@ class SettingsModel extends Model /** * @var int */ - public $expirationTime = 60; + public $minimumSubmitTime = 1; /** * @var int */ - public $minimumSubmitTime = 1; + public $expirationTime = 60; /** * @var array|string diff --git a/src/templates/_settings.html b/src/templates/_settings.html index 34cd3f3..68e8fed 100644 --- a/src/templates/_settings.html +++ b/src/templates/_settings.html @@ -11,7 +11,6 @@ {{ forms.lightswitchField({ first: true, - required: true, label: 'Validation Enabled'|t('snaptcha'), name: 'validationEnabled', instructions: 'Whether form submissions should be validated. Ensure that all of your forms that submit via POST requests have the necessary tags in place before enabling this.'|t('snaptcha'), @@ -21,7 +20,6 @@ }) }} {{ forms.lightswitchField({ - required: true, label: 'Validate Users'|t('snaptcha'), name: 'validateUsers', instructions: 'Whether form submissions should be validated for logged-in users (recommended if public user registration is enabled).'|t('snaptcha'), @@ -31,7 +29,6 @@ }) }} {{ forms.lightswitchField({ - required: true, label: 'One Time Key'|t('snaptcha'), name: 'oneTimeKey', instructions: 'Whether form submissions should be limited to one time per page refresh (recommended for low to medium traffic sites).'|t('snaptcha'), @@ -41,7 +38,6 @@ }) }} {{ forms.lightswitchField({ - required: true, label: 'Log Rejected'|t('snaptcha'), name: 'logRejected', instructions: 'Whether rejected form submissions should be logged (log will be written to `{log}`).'|t('snaptcha', {log: alias('@storage/logs/snaptcha.log')}), @@ -112,17 +108,6 @@ errors: settings.getErrors('errorTemplate') }) }} -{{ forms.textField({ - type: 'number', - required: true, - label: 'Expiration Time'|t('snaptcha'), - name: 'expirationTime', - instructions: 'The expiration time for form submissions in minutes.'|t('snaptcha'), - warning: (config.expirationTime is defined ? configWarning('expirationTime')), - value: settings.expirationTime, - errors: settings.getErrors('expirationTime'), -}) }} - {{ forms.textField({ type: 'number', required: true, @@ -134,6 +119,17 @@ errors: settings.getErrors('minimumSubmitTime'), }) }} +{{ forms.textField({ + type: 'number', + required: true, + label: 'Expiration Time'|t('snaptcha'), + name: 'expirationTime', + instructions: 'The expiration time for form submissions in minutes.'|t('snaptcha'), + warning: (config.expirationTime is defined ? configWarning('expirationTime')), + value: settings.expirationTime, + errors: settings.getErrors('expirationTime'), +}) }} + {{ hiddenInput('excludeControllerActions', '') }} {{ forms.editableTableField({ label: 'Exclude Controller Actions'|t('snaptcha'),