diff --git a/CHANGELOG.md b/CHANGELOG.md index 6450906..faf0d7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# v3.0.9 +## 06/08/2020 + +1. [](#improved) + * Disable password autocomplete in password field + * Don't save empty string in password field [#134](https://github.com/getgrav/grav-plugin-email/issues/134) + # v3.0.8 ## 04/27/2020 diff --git a/blueprints.yaml b/blueprints.yaml index 8f4858e..f5b7979 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Email slug: email type: plugin -version: 3.0.8 +version: 3.0.9 testing: false description: Enables the emailing system for Grav icon: envelope @@ -20,6 +20,7 @@ dependencies: form: validation: loose + fields: enabled: type: hidden @@ -170,13 +171,13 @@ form: mailer.smtp.user: type: text size: medium - autocomplete: nope + autocomplete: 'off' label: PLUGIN_EMAIL.SMTP_LOGIN_NAME mailer.smtp.password: type: password size: medium - autocomplete: nope + autocomplete: 'new-password' label: PLUGIN_EMAIL.SMTP_PASSWORD sendmail_config: diff --git a/email.php b/email.php index ec82f3b..8879aed 100644 --- a/email.php +++ b/email.php @@ -1,6 +1,7 @@ ['onFormProcessed', 0], 'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0], 'onSchedulerInitialized' => ['onSchedulerInitialized', 0], + 'onAdminSave' => ['onAdminSave', 0], ]; } @@ -48,6 +50,28 @@ public function onTwigTemplatePaths() $twig->twig_paths[] = __DIR__ . '/templates'; } + /** + * Force compile during save if admin plugin save + * + * @param Event $event + */ + public function onAdminSave(Event $event) + { + /** @var Data $obj */ + $obj = $event['object']; + + + + if ($obj instanceof Data && $obj->blueprints()->getFilename() === 'email/blueprints') { + $current_pw = $this->grav['config']->get('plugins.email.mailer.smtp.password'); + $new_pw = $obj->get('mailer.smtp.password'); + if (!empty($current_pw) && empty($new_pw)) { + $obj->set('mailer.smtp.password', $current_pw); + } + + } + } + /** * Send email when processing the form data. *