Skip to content

Conversation

@peterfabian
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

Closes #31035.

How to test the changes in this Pull Request:

  1. Set up a new WC store, use this PR.
  2. Go to Woo > Settings > Accounts & Privacy and enable Allow customers to create an account during checkout
    and Allow customers to create an account on the "My account" page while letting WC generate username and password.
  3. Add a product and enable one payment gw.
  4. Go through the checkout and enable the checkbox to create a new user account.
  5. Verify the email receives a link to set a new password instead of the password itself.
  6. Check that you can set the password and log in with it.
  7. Try to register/create the user account from My Account page.
  8. Repeat steps 5 & 6
  9. Go to Woo > Settings > Accounts & Privacy and disable creating of the new password automatically.
  10. Create a new user account through checkout.
  11. Check that the email doesn't contain the link to set a new password.
  12. Create a new user account through My Account page.
  13. Check that the email doesn't contain the link to set a new password.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Add set password link to emails when creating new user account.

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@peterfabian peterfabian requested review from a team and Konamiman and removed request for a team November 19, 2021 16:24
Copy link
Contributor

@vedanshujain vedanshujain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and testing well! Left a minor stability comment

'sent_to_admin' => false,
'plain_text' => false,
'email' => $this,
'set_password_url' => $this->set_password_url,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this guaranteed to be set before it's called? if not, then maybe we can create a getter method for set_password_url which will either generate the password URL if it does not exist yet, or return the generated URL if it already exist. wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. I assumed it would be fine, because in the same place we use $this->user_login and $this->user_pass that are set in the same place (the trigger method in the same class).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that's sufficient guarantee or shall we switch those to getters as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a public method, so we don't know when it could be called. That said, I'm approving because your explanation makes sense and should have been set in trigger class.

'sent_to_admin' => false,
'plain_text' => true,
'email' => $this,
'set_password_url' => $this->set_password_url,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, this could be null before it's called.

Copy link
Contributor

@vedanshujain vedanshujain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@Konamiman Konamiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me too, tested all the cases in the PR description and it works as expected.

@peterfabian peterfabian merged commit ab1a357 into trunk Nov 22, 2021
@peterfabian peterfabian deleted the fix/31035 branch November 22, 2021 17:43
@peterfabian peterfabian added this to the 6.0.0 milestone Nov 22, 2021
@github-actions github-actions bot modified the milestones: 6.0.0, 6.1.0 Nov 22, 2021
@github-actions
Copy link
Contributor

Hi @peterfabian, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the status: needs changelog label
  • Add the status: needs testing instructions label

@peterfabian peterfabian added release: cherry-pick Commits from this PR also needs to be added to current release branch. release: add changelog Mark all PRs that have not had their changelog entries added. [auto] release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Nov 22, 2021
@ObliviousHarmony ObliviousHarmony modified the milestones: 6.1.0, 6.0.0 Nov 30, 2021
@rodelgc rodelgc added testing instructions added and removed release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Dec 7, 2021
@ObliviousHarmony ObliviousHarmony added changelog added and removed release: add changelog Mark all PRs that have not had their changelog entries added. [auto] release: cherry-pick Commits from this PR also needs to be added to current release branch. labels Dec 8, 2021
@ghost
Copy link

ghost commented Dec 27, 2021

Hi team, I wanted to know that is this feature available to the users now? I updated my plugin to 6.0.0 but still the password is being sent to the users via email.

@peterfabian
Copy link
Contributor Author

Hi @avidews . I just tested a fresh installation with WC 6.0 and tried creating a new account via
1.checkout and
2. My Account page.

In both cases, the email I got didn't include the password. Which workflow are you using to create a user account? Does your website maybe use custom templates you need to adjust according to how it's been done for the default templates?

  • templates/emails/customer-new-account.php
  • templates/emails/plain/customer-new-account.php
  • templates/myaccount/form-login.php

@ghost
Copy link

ghost commented Jan 4, 2022

Hi @peterfabian.

Thanks a lot for your reply. You just solved my problem, my website is using a plugin for custom email templates and the new account email template is still using {user_pass}. I think I need to contact the plugin team to update their plugin?

Thanks lot for your help.

@peterfabian
Copy link
Contributor Author

Great to hear. Yes, exactly, please contact the plugin authors.

@solaceten
Copy link

solaceten commented Feb 2, 2022

Greetings all and @peterfabian @rodelgc @melek

I think this is an improvement over sending plain text password, so good call!

Two questions (and I am not sure if I need to open a new ticket for this)...

  1. When I did a test account creation, I got the welcome email with the link that invited me to set a new password which was great - however, I also received a plain text "Password Changed" notification email along the lines of "This notice confirms that your password on [website] was recently changed. If you did not change your password, please contact....." etc...

Is that the correct behaviour? Because it seems unnecessary to send it to a new user that has just registered.

  1. If we are now inviting customers to set a password - why not go back to doing that at the checkout, so that it is all done in one place (rather than another email process!)

Thanks

@melek
Copy link

melek commented Feb 3, 2022

  1. When I did a test account creation, I got the welcome email with the link that invited me to set a new password which was great - however, I also received a plain text "Password Changed" notification email along the lines of "This notice confirms that your password on [website] was recently changed. If you did not change your password, please contact....." etc... Is that the correct behavior?

The 'Password Changed' emails are part of WordPress. They can be disabled on your site with a filter, see this forum post for more details:

https://wordpress.org/support/topic/disable-password-changed-emails-2/

I agree with you that suppressing these emails when a new customer initially sets their password is worth considering :) If you want that functionality, I recommend filing an issue so it can be discussed.

If we are now inviting customers to set a password - why not go back to doing that at the checkout, so that it is all done in one place (rather than another email process!)

Different shop owners will have different preferences on checkout and account creation flow; I for instance think that asking the customer to go through an email process encourages extra engagement. In any case, opining on how store owners should have users set passwords is outside the scope of this change. I also don't see any reason to remove an option from the Accounts & Privacy area.

@ktmn
Copy link

ktmn commented Aug 6, 2022

Should have maybe bumped templates/myaccount/form-login.php version cause a string changed? I was wondering why A link to set a new password will be sent to your email address. wasn't translating, I still had A password will be sent to your email address. in my theme's override but no notice that the template had been updated.

@peterfabian
Copy link
Contributor Author

peterfabian commented Aug 12, 2022

@ktmn Yup, that was missed, unfortunately. Fixed in #34308

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

STOP sending passwords via e-mail Please

9 participants