Skip to content

Commit

Permalink
Merge branch 'release/3.0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jun 8, 2020
2 parents 8ebf026 + 9c7f5a5 commit 859fa08
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
7 changes: 4 additions & 3 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,6 +20,7 @@ dependencies:

form:
validation: loose

fields:
enabled:
type: hidden
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions email.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Grav\Plugin;

use Grav\Common\Data\Data;
use Grav\Common\Plugin;
use Grav\Plugin\Email\Email;
use RocketTheme\Toolbox\Event\Event;
Expand All @@ -22,6 +23,7 @@ public static function getSubscribedEvents()
'onFormProcessed' => ['onFormProcessed', 0],
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
'onSchedulerInitialized' => ['onSchedulerInitialized', 0],
'onAdminSave' => ['onAdminSave', 0],
];
}

Expand All @@ -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.
*
Expand Down

0 comments on commit 859fa08

Please sign in to comment.