Problem/Motivation

Module to provide configurable mail body and subject content (which has the added benefit of being consistent with the user module - for registrations etc.) it’ll be easier to manage content ongoing. It would also enable the use of tokens in mail content.
Currently the module has hardcoded email content in the module for reset and pending password emails.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joshua1234511 created an issue. See original summary.

joshua1234511’s picture

joshua1234511’s picture

Password policy email form added at /admin/config/system/password_policy/emails
Configuration added "password_policy.email"

joshua1234511’s picture

Status: Active » Needs review
joshua1234511’s picture

StatusFileSize
new102.32 KB
new51.28 KB
new11.15 KB
new26.05 KB

Moving the the password policy emails as they are another user account-related emails, they should come in the central place for email templates: /admin/config/people/accounts

The last submitted patch, 6: 3240363-6.diff, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

joshua1234511’s picture

StatusFileSize
new11.15 KB
new11.51 KB

Moving the the password policy emails as they are another user account-related emails, they should come in the central place for email templates: /admin/config/people/accounts

The last submitted patch, 10: 3240363-10.diff, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 10: 3240363-10.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

joshua1234511’s picture

Status: Needs work » Needs review
StatusFileSize
new10.92 KB
new12.44 KB

The last submitted patch, 13: 3240363-11.diff, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

joshua1234511’s picture

StatusFileSize
new10.92 KB
new14.92 KB

Updated Render() method to tostring getGeneratedLink().

paulocs’s picture

this looks a nice feature and it will be welcome.

huriellopes’s picture

Status: Needs review » Reviewed & tested by the community

Steps performed:
(1) Module installed
(2) Reproduction of the problem.
(3) Patch applied.
(4) Code review on changes.
(5) Retested with patch, issue resolved.

paulocs’s picture

Status: Reviewed & tested by the community » Needs work

This issue is not ready yet because the tests are failing.

hmendes made their first commit to this issue’s fork.

hmendes’s picture

Status: Needs work » Needs review
joshua1234511’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new13.27 KB
new27.49 KB
new52.56 KB

Retested the patch after changes from @hmendes.
Working as feature expected.
@huriellopes please reconfirm the same.

danthorne’s picture

Patch 21 not working with latest dev

danthorne’s picture

Status: Reviewed & tested by the community » Needs work
gquisini’s picture

Assigned: Unassigned » gquisini

I'll try to work on it

gquisini’s picture

Assigned: gquisini » Unassigned
Status: Needs work » Needs review
StatusFileSize
new12.93 KB

I basically made a reroll from #21 patch.

2gendevs’s picture

Patch from #25 fails to apply.

Patch from #21 breaks the form at /admin/config/people/accounts for the other emails. i.e. you can't save "welcome (new user created by administrator) or any of the other non-password policy emails. No error messages or success message. It just doesn't save. Removing the patch allows me to save the emails again.

Tested on Drupal 9.4.5.

Fixing it by changing the following in the patch password_policy_form_user_admin_settings_alter() function (password_policy.module)

$form['actions']['submit']['#submit'][] = '_password_policy_form_email_settings_submit';

to

$form['#submit'][] = '_password_policy_form_email_settings_submit';
2gendevs’s picture

StatusFileSize
new526 bytes

My fix from above, should be applied after patch 21.

lucasbaralm’s picture

Assigned: Unassigned » lucasbaralm

i will work on this.

lucasbaralm’s picture

StatusFileSize
new13.4 KB
new7.83 KB

(Still working in it as the patch failed to apply) Basically, I made some minor tweaks to patch #25 to be applicable in the actual branch and merged the changes from #27 into it.

lucasbaralm’s picture

StatusFileSize
new5.32 KB

Trying to make patch #29 applicable with branch 3240363-module-to-provide. It work locally but failed to apply on remote.

lucasbaralm’s picture

Assigned: lucasbaralm » Unassigned
Status: Needs review » Needs work
sophiavs’s picture

Assigned: Unassigned » sophiavs

I'll analyze the error in the patch.

sophiavs’s picture

Status: Needs work » Needs review
StatusFileSize
new10.87 KB

I united all the patches and analyzed then, some of the patchs was missing parts from other patchs and that caused the patch failed to apply. Also, i couldn't find the file PasswordPolicyGeneralForm.php is in the dev, so i removed those parts from the patch

Status: Needs review » Needs work

The last submitted patch, 33: 3240363-33.patch, failed testing. View results

paulocs’s picture

PasswordPolicyGeneralForm.php was removed in #2877040: Remove dependency on CTools
It still needs work because tests are failing

sophiavs’s picture

StatusFileSize
new10.87 KB

Sorry, i had made a change to test and created the patch without changing back.
That is the correct one.

sophiavs’s picture

Status: Needs work » Needs review
StatusFileSize
new10.87 KB

I don't know why the new file isn't saved on the diff

Status: Needs review » Needs work

The last submitted patch, 37: 3240363-37.patch, failed testing. View results

sophiavs’s picture

Assigned: sophiavs » Unassigned
Status: Needs work » Needs review
StatusFileSize
new11.55 KB
victorml’s picture

Status: Needs review » Reviewed & tested by the community

I tested and reviewed it, and everything works fine.

Tests are passing too.

l-laziz’s picture

The feature/issue is still relevant for 4.x version and the patch #39 applies to 4.0.0 module version cleanly.

l-laziz’s picture

Version: 8.x-3.x-dev » 4.0.0
shaunlaws’s picture

StatusFileSize
new11.51 KB

This patch does apply cleanly to 4.0.0, but caused a failure when I upgraded a site from D9 to D10.1.4. When running 'drush updb' it failed in password_policy_update_8305 at:

$config_path = drupal_get_path('module', 'password_policy') . '/config/install/password_policy.email.yml';

because drupal_get_path was removed from D10 - https://www.drupal.org/node/2940438.

I suppose one upgrade path would be to apply the patch to the D9 site and run 'drush updb', but the path of least resistance for me was to re-roll the patch in #39 to change the failing statement to one which is compatible with both D9 and D10:

$config_path = \Drupal::service('extension.list.module')->getPath('password_policy') . '/config/install/password_policy.email.yml';

I have only tested the patch when running password_policy_update_8305 on a D10 site but it *should* work on D9 also.

greggles’s picture

This feature seems pretty unrelated to the purpose of the module.

simon-p’s picture

StatusFileSize
new312.74 KB

As the person who submitted issue https://www.drupal.org/project/password_policy/issues/3292927 I have to say it it seems very related.

Here is an example of what our currently staff receive:

Email text

The text 'your password will expire soon' does not give any indication of what password needs changing, or even that it is a website password. If the person receiving it does not know which password needs changing they are unlikely to do it, which defeats the purpose of the module.

Given that password reset reminders are a commonly used in spam, people are going to ignore the email if there is no specific text that helps them identify that the email is genuine.

simon-p’s picture

kristen pol’s picture

Assigned: Unassigned » kristen pol

Assigning to myself as I'm reviewing/merging ready RTBC fixes/updates over the next few days.

kristen pol’s picture

Thanks everyone for working on this issue. I haven't read all the comments yet but regarding #44:

This feature seems pretty unrelated to the purpose of the module.

The email feature is already part of this module, so making the text configurable like other core user emails makes sense to me.

There are lot of patches and MRs updates so this is a bit hard to follow.

For example, it doesn't look like the latest patch included the fix noted in #26.

I'll look a bit more but this probably will need more work.

kristen pol’s picture

Assigned: kristen pol » Unassigned
Status: Reviewed & tested by the community » Needs work

I've reviewed the code, but didn't test anything. Moving back to "needs work" based on the following:

Ignore my note above about #26. I thought the logic was reversed, so it looks okay.

One thing I noticed was that core uses type: mail in the schema, but that's not used in this code, e.g.

user.mail:
  type: config_object
  label: 'Email settings'
  mapping:
    cancel_confirm:
      type: mail
      label: 'Account cancellation confirmation'
    password_reset:
      type: mail
      label: 'Password recovery'
    register_admin_created:
      type: mail
      label: 'Account created by administrator'
    register_no_approval_required:
      type: mail
      label: 'Registration confirmation (No approval required)'
    register_pending_approval:
      type: mail
      label: 'Registration confirmation (Pending approval)'
    register_pending_approval_admin:
      type: mail
      label: 'Admin (user awaiting approval)'
    status_activated:
      type: mail
      label: 'Account activation'
    status_blocked:
      type: mail
      label: 'Account blocked'
    status_canceled:
      type: mail
      label: 'Account cancelled'

    Some other observations:

  1. +++ b/config/schema/password_policy.schema.yml
    @@ -57,3 +57,26 @@ password_policy.settings:
    +password_policy.email:
    

    Nitpick: Inconsistent use of email vs mail throughout code. Ideally, be consistent in usage throughout this code or be consistent with core naming if that is different.

  2. +++ b/config/schema/password_policy.schema.yml
    @@ -57,3 +57,26 @@ password_policy.settings:
    +  label: 'Password to expire'
    

    This label needs to change because this config object has both the "expired" and "to expire" info.

  3. +++ b/password_policy.module
    @@ -13,6 +13,8 @@ use Drupal\user\UserInterface;
     use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
     use Drupal\Core\Url;
    +use Drupal\Component\Render\PlainTextOutput;
    +use Drupal\Core\Render\BubbleableMetadata;
    

    Nitpick: Should be in alphabetical order.

  4. +++ b/password_policy.module
    @@ -534,3 +543,97 @@ function password_policy_help($route_name, RouteMatchInterface $route_match) {
    +    'description' => t('Url of the site, no language prefix garanted'),
    

    Wrong description.

  5. +++ b/tests/src/Functional/PasswordExpiredEmailSendTest.php
    @@ -131,10 +131,10 @@ class PasswordExpiredEmailSendTest extends BrowserTestBase {
    +    $this->assertMailString('body', "Your password will expire in less than $days_left days. Please visit the following link to reset your password: $link ", 1);
    

    Empty space after $link. Is that expected?

  6. +++ b/tests/src/Functional/PasswordExpiredEmailSendTest.php
    @@ -147,10 +147,10 @@ class PasswordExpiredEmailSendTest extends BrowserTestBase {
    +    $this->assertMailString('body', "Your password will expire in less than $days_left days. Please visit the following link to reset your password: $link ", 1);
    

    Same.

sgoodwin’s picture

StatusFileSize
new11.88 KB

This patch failed to apply with version 4.0.2. So this is the reroll of the patch 2023_09_21_3240363-40.patch.

bdunphy’s picture

Patch in comment #50 works well so far on 4.0.3. Thank you to all who worked on this.

codebymikey made their first commit to this issue’s fork.

codebymikey’s picture

StatusFileSize
new12.19 KB

Attached static patch of the current MR, with improved compatibility with Drupal 11