Problem/Motivation
The demo author and editor users are created without a known password. People doing demos need to use drush uli or manually edit user passwords which is disrupting a nice demo if shown from the installation onwards.
Proposed resolution
To make it easier to demonstrate Drupal, it would be great if all users use the same admin password that user 1 gets. Since demos are intended to be ephemeral, I don't expect this to be a problem.
Remaining tasks
Discuss.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | core_demo_umami-3045966-18.patch | 4.48 KB | partyka |
| #16 | core_demo_umami-3045966-16.patch | 3.23 KB | partyka |
| #14 | core_demo_umami-3045966-14.patch | 2.25 KB | partyka |
| #12 | core_demo_umami-3045966-12.patch | 2.39 KB | partyka |
| #11 | core_demo_umami-3045966-11.patch | 2.61 KB | partyka |
Comments
Comment #2
mglaman+1 from this end. Unami can add an install task which copies the admin user's `passRaw`, if available or copies the hash over to the other users. I'm not sure if the data could be retrieved from the form in later tasks.
This would make the demo much easier to interact with.
Comment #3
wim leersThe users are currently indeed created without a password: https://git.drupalcode.org/project/drupal/blob/8.8.x/core/profiles/demo_... — this was done in #2809635: Create experimental installation profile, so you can't log in with them. To log in as these users, have the admin user assign them a password first (or use
drush uli).+1 to the proposed solution from Gábor: that seems entirely reasonable for demo installs.
Comment #4
shaalI created a function that gets all users in the system with roles 'author' and 'editor' and sets their password to be the same as the admin's password.
This function is called in 2 places:
Comment #5
shaalComment #6
partyka commentedI have tested this patch locally with Drupal 8.7, and have been able to login with the generated password for all six generated users:
Samuel Adamson
Megan Collins Quinlan
Holly Foat
Umami
Grace Hamilton
Margaret Hopper
Comment #8
partyka commentedThere were multiple ` PDOStatement::execute(): MySQL server has gone away` statements in the test run output.
Retriggering.
Comment #9
partyka commentedTests pass again, restoring RTBC.
Comment #10
berdirThere are various things here wrong, most importantly, you must never directly write entity tables but use the entity API.
You can set the pre_hashed attribute to save an already hashed password, you should also use the injected $entityTypeManager to load entities, query for them and so on.
I don't understand what this is doing, just add the code in this method, no need for set_users_passwords()?
Comment #11
partyka commentedWe're working on this in the sprint room and have completely changed this around.
It's been simplified to grab the admin's password out of the install form and then apply it to all the users when that form is submitted.
Greatly simplifies the amount of code changed.
I've tested this with both the normal UI installer (user admin/password food) and the drush installer (`drush site-install --account-pass=food demo_umami`), and all users were successfully given the 'food' password.
Please note that it's not entirely clear on how to test this one. Is it necessary?
Comment #12
partyka commentedRemoved unused use statement.
Comment #13
partyka commentedComment #14
partyka commentedI left a debugging variable in :-(....
Took it out in this patch (#14)
Comment #15
wim leersThanks a lot for working on this, @partyka! 👍
This is not doing anything anymore, I think we can probably remove it?
I think this is a debug leftover :)Hah, you fixed that while I was writing this, awesome! 👏
This can become even simpler:
\Drupal\demo_umami_content\InstallHelper::importEditors()always creates the same two users, with the same two names and the same two IDs. So we don't even need an entity query :)The changes in this class can be reverted now! :)
Comment #16
partyka commentedUploaded a new patch and a test thanks to tedbow's help :-)
I've removed the old code no longer needed.
But I think it makes sense to say to add everyone in the author or editor roles, as there are currently six users.
Comment #17
partyka commentedAnd @Wim Leers, thank you for your review!
@tedbow also needs credit on this, he helped me with the test.
Comment #19
kjay commentedGreat work, thanks for working on this patch! From a functional point of view, this patch applied cleanly and I've been able to log in to all the accounts, both editors and authors, using the same password created for admin.
Comment #20
partyka commentedCode style cleanup.
Comment #21
wim leersThanks for bearing with us and fixing those nitpicks! 🙏 😃
Comment #22
shaal+1 RTBC
I tested it with Drupal installation using the GUI, and then tested it using
drush si demo_umami.Both methods worked as planned, all users got the same password as admin.
Comment #23
shaalComment #26
gábor hojtsySuperb, thanks all!