Skip to content

Commit 37b0933

Browse files
authored
Merge pull request #1040 from YevhenZvieriev/feature/admin-user-create
Added script for creating Magento admin user and customer
2 parents c3c31d1 + 8cad6b6 commit 37b0933

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

README.md

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

compose/Makefile

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

compose/bin/create-user

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
read -r -p "Create an admin (a) or a customer (c)? [a/c]: " account_type
4+
[[ "$account_type" == [Aa] ]] && read -r -p "Username: " USERNAME
5+
read -r -p "Email: " EMAIL
6+
read -r -p "Password (at least 8 characters): " PASSWORD
7+
read -r -p "First Name: " FIRSTNAME
8+
read -r -p "Last Name: " LASTNAME
9+
10+
if [[ "$account_type" == [Aa] ]]; then
11+
bin/magento admin:user:create \
12+
--admin-user="${USERNAME}" \
13+
--admin-password="${PASSWORD}" \
14+
--admin-email="${EMAIL}" \
15+
--admin-firstname="${FIRSTNAME}" \
16+
--admin-lastname="${LASTNAME}"
17+
elif [[ "$account_type" == [Cc] ]]; then
18+
bin/n98-magerun2 customer:create "${EMAIL}" "${PASSWORD}" "${FIRSTNAME}" "${LASTNAME}"
19+
else
20+
echo "Invalid option. Please choose either a or c."
21+
fi

0 commit comments

Comments
 (0)