Przeglądaj źródła

Merge pull request #1040 from YevhenZvieriev/feature/admin-user-create

Added script for creating Magento admin user and customer
Mark Shust 1 rok temu
rodzic
commit
37b09334fb
3 zmienionych plików z 23 dodań i 0 usunięć
  1. 1 0
      README.md
  2. 1 0
      compose/Makefile
  3. 21 0
      compose/bin/create-user

+ 1 - 0
README.md

@@ -279,6 +279,7 @@ It is recommended to keep your root docker config files in one repository, and y
 - `bin/composer`: Run the composer binary. Ex. `bin/composer install`
 - `bin/copyfromcontainer`: Copy folders or files from container to host. Ex. `bin/copyfromcontainer vendor`
 - `bin/copytocontainer`: Copy folders or files from host to container. Ex. `bin/copytocontainer --all`
+- `bin/create-user`: Create either an admin user or customer account.
 - `bin/cron`: Start or stop the cron service. Ex. `bin/cron start`
 - `bin/dev-urn-catalog-generate`: Generate URN's for PhpStorm and remap paths to local host. Restart PhpStorm after running this command.
 - `bin/devconsole`: Alias for `bin/n98-magerun2 dev:console`

+ 1 - 0
compose/Makefile

@@ -27,6 +27,7 @@ help:
 	@echo "$(call format,composer,'Run the composer binary.')"
 	@echo "$(call format,copyfromcontainer,'Copy folders or files from container to host.')"
 	@echo "$(call format,copytocontainer,'Copy folders or files from host to container.')"
+	@echo "$(call format,create-user,'Create either an admin user or customer account.')"
 	@echo "$(call format,cron,'Start or stop the cron service.')"
 	@echo "$(call format,dev-urn-catalog-generate,'Generate URNs for PHPStorm and remap paths to local host.')"
 	@echo "$(call format,devconsole,'Alias for n98-magerun2 dev:console.')"

+ 21 - 0
compose/bin/create-user

@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+read -r -p "Create an admin (a) or a customer (c)? [a/c]: " account_type
+[[ "$account_type" == [Aa] ]] && read -r -p "Username: " USERNAME
+read -r -p "Email: " EMAIL
+read -r -p "Password (at least 8 characters): " PASSWORD
+read -r -p "First Name: " FIRSTNAME
+read -r -p "Last Name: " LASTNAME
+
+if [[ "$account_type" == [Aa] ]]; then
+  bin/magento admin:user:create \
+    --admin-user="${USERNAME}" \
+    --admin-password="${PASSWORD}" \
+    --admin-email="${EMAIL}" \
+    --admin-firstname="${FIRSTNAME}" \
+    --admin-lastname="${LASTNAME}"
+elif [[ "$account_type" == [Cc] ]]; then
+  bin/n98-magerun2 customer:create "${EMAIL}" "${PASSWORD}" "${FIRSTNAME}" "${LASTNAME}"
+else
+    echo "Invalid option. Please choose either a or c."
+fi