docker-magento
docker-magento copied to clipboard
Added script for creating Magento admin user
Added a script bin/create-user
to automate the creation of a Magento admin user and customer. The script utilizes the bin/magento admin:user:create
command with predefined values for the admin user, and n98 for creating a customer.
PR Summary
- Admin User Creation Script Added A new tool has been included in the package that allows for creation of administrator users in the Magento platform. The tool is user-friendly as it prompts for the necessary details including username, email, and full names, then uses this information to set up a new user. It also checks for any problems during setup, alerting users if their setup did not proceed correctly for instant troubleshooting.
By the way, I can modify this script so that the user can create an admin user or new customer account.
@YevhenZvieriev thanks! I think we should prompt the user for input though, and fall back to defaults if they just "enter" through the script though, no?
I like your idea of extending this script to also apply to customer accounts. Perhaps we can rename this to bin/create-user
, and then also prompt them if they want to create an admin or a customer with the first prompt? It may also make sense to allow them to pass in one or more params/args too, which would bypass the prompt if they do so (and passing in all of the args would basically pipe the entire command to bin/magento admin:user:create
.
I think this makes sense... let me know if it does or not.
Hi, @markshust
Good idea!
I`ll do it in my next commit.
Updated 25.02.2024:
Admin User Creation: The script includes a function to create an admin user account, allowing customization of username, email, first name, last name, and password.
Customer Account Creation: Another function enables the creation of customer accounts, with the option to either use default values or input custom details for email, password, first name, last name, and website.
Dependency-Check: It checks for the existence of n98-magerun2.phar and downloads it if not found, ensuring the necessary tool for Magento CLI operations is available, n98 is used for creating customer accounts.
User Interaction: The script prompts the user to choose between creating an admin or a customer account and provides prompts for further customization if required.
How added features work:
Hi, @markshust
I took into account all your amendments and simplified the script. Now it's four times shorter, but it works as well as before. Feel free to check it!
@YevhenZvieriev I feel as though the script was still way too unnecessarily complex.
I think you removed something that shouldn't have been removed (which is the standardization of inputs between the two accounts). It'd be nice for both of these scripts to share the same prompts for email, password, etc. rather than the disconnect between the Magento and magerun scripts.
Also, there were unneeded references to n98-magerun2. Again, all of the functionality to download, install, check n98-magerun2 is in the https://github.com/markshust/docker-magento/blob/master/compose/bin/n98-magerun2 file, so we don't need it anywhere else. There were also same malformed indentations which I removed.
All code in this project strives for elegance + simplicity -- if it doesn't match either of those two aspects, it will always be denied, hung up for a long while, or closed out and not merged.
I updated this PR, and appreciate your initial one! But as a case-study for future PR's, I'd compare:
- The initial PR: https://github.com/markshust/docker-magento/blob/9d1940da4e2e1c6cedf944c8f95c33141d3e724d/compose/bin/create-user
- The final PR: https://github.com/markshust/docker-magento/blob/b6521c303b449bbacbf5e4319af9de8d7220a4cd/compose/bin/create-user
This is 85 lines vs 21 lines. This is less code to maintain, it's easier to read the file and understand what is going on, and it's very elegant -- it doesn't do anything that it doesn't need to do. But, it does just enough to add some extra functionality that goes above and beyond what someone would expect.
Every helper script created also needs a corresponding addition to the README, describing the script, and also added to the Makefile! (something that I routinely forget 😅) https://github.com/markshust/docker-magento/pull/1040/commits/8cad6b6aea106d4d750c5ba25ec9dc314d246995