At present, users are imported with a name, status=1, and nothing else. #2953376: Adopt Content Moderation in Umami already proposes adding sensible roles to users. Should we not also follow normal practice and create email addresses, passwords(?), ... (anything else?)

I'll refrain from creating a patch just yet until #2983573: Use migrate to build Umami content rather than bespoke code. starts to take shape.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

martin_q created an issue. See original summary.

Eli-T’s picture

Title: Sensibly populate users » Add example.com email addresses to users created during Umami install

There is value in proceding with this independently of #2953376: Adopt Content Moderation in Umami as that is blocked on Migrate Source CSV coming in to core, and whilst that is an aspiration for 8.6.x, there are no guarantees at this point it will make it. But there may be value in doing this change in the meantime.

I would suggest we should create email addresses in the form firstname.lastname@example.com to avoid an Umami install sending emails to real people under any circumstances unless users have added edited them.

Setting passwords however is a no-go. If we did this, then any publicly routable Umami install would have default working credentials publically available.

The patch at #2953376: Adopt Content Moderation in Umami creates roles and assigns an Author role to the users. I suggest we leave that functionality there.

Renaming this issue as I think email addresses are the only thing to do specifically here.

martin_q’s picture

Good call on all these points.

rattusrattus’s picture

Eli-T’s picture

Status: Active » Needs review
Issue tags: +DevDaysLisbon
Eli-T’s picture

Status: Needs review » Reviewed & tested by the community

I've reviewed the code in the patch and it looks good. I've tested it on simplytest.me and confirmed all the users now have email addreses in the correct format, all for the domain example.com so will never be usable for a password reset.

I do note that we have two users Megan Collins Quinlan and Megan Collins, where I suspect the intention was to have a single user. However, this was introduced in #2960483: Add an article to Umami - Mocktails so shouldn't hold up this issue.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Crediting @Eli-T for issue review and @martin_q for issue creation.

+++ b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php
@@ -405,6 +405,7 @@ protected function getUser($name) {
+        'mail' => $this->getUserEmail($name),

@@ -415,6 +416,21 @@ protected function getUser($name) {
+  protected function getUserEmail($name) {
+    return mb_strtolower(str_replace(' ', '.', $name)) . '@example.com';
+  }

Let's not add a new function this could get confusing if someone expects it to alway get the demo user email even if it has been changed. Less API. If you need the users email later we can get it from the user object.

So we can do:

'mail' => mb_strtolower(str_replace(' ', '.', $name)) . '@example.com',
zuhair_ak’s picture

Status: Needs work » Needs review
FileSize
648 bytes
1.06 KB

Made the changes and added the patch.

John Cook’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch zuhair_ak.

This addresses alexpott's comments in #7. Makes a nice, small patch.

After installation, the users have email addresses in the format of full.name@example.com.

I'm setting to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 78699ba and pushed to 8.6.x. Thanks!

  • alexpott committed 78699ba on 8.6.x
    Issue #2983591 by zuhair_ak, rattusrattus, martin_q, Eli-T, alexpott,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.