Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added script for creating Magento admin user and customer #1040

Merged
merged 10 commits into from
Mar 19, 2024

Conversation

YevhenZvieriev
Copy link
Contributor

@YevhenZvieriev YevhenZvieriev commented Jan 11, 2024

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.

admin-user-create

Copy link

what-the-diff bot commented Jan 11, 2024

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.

@YevhenZvieriev
Copy link
Contributor Author

By the way, I can modify this script so that the user can create an admin user or new customer account.

@markshust
Copy link
Owner

@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.

@YevhenZvieriev
Copy link
Contributor Author

Hi, @markshust

Good idea!

I`ll do it in my next commit.

@YevhenZvieriev
Copy link
Contributor Author

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:

Screencast.from.2024-02-25.01-37-40.webm

@YevhenZvieriev YevhenZvieriev changed the title Added script for creating Magento admin user Added script for creating Magento admin user and customer Mar 6, 2024
Copy link
Owner

@markshust markshust left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! But I'd like this script simplified, as there is too much going on in the code and it can be made more intuitive with the suggested updates.

compose/bin/create-user Outdated Show resolved Hide resolved
compose/bin/create-user Outdated Show resolved Hide resolved
compose/bin/create-user Outdated Show resolved Hide resolved
compose/bin/create-user Outdated Show resolved Hide resolved
compose/bin/create-user Outdated Show resolved Hide resolved
compose/bin/create-user Outdated Show resolved Hide resolved
@YevhenZvieriev
Copy link
Contributor Author

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!

Standardized bash input prompt for the creation of either account and removed unneeded functions
Fixed shellcheck to prevent globbing and splitting.
@markshust
Copy link
Owner

@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:

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.

@markshust
Copy link
Owner

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 😅) 8cad6b6

@markshust markshust merged commit 37b0933 into markshust:master Mar 19, 2024
1 check passed
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.

2 participants