previous page. It is important to note that any user added this way will be automatically verified.
You can list all registered users in a nice table as shown below:
$ api-admin user list
This will show Id, Email address, First and Last name, Role, and the Verified and Banned Status.
Warning
This list could be rather large and be produced slowly if you have a very popular site!
In future versions I'll add an auto-paging facilty if the numbers are large.
$ api-admin user show 23
This will show the same data as above, but for only one user. You must specify the user ID.
You can verify a user as being valid from the CLI. This allows them to login without needing to use the validation email. Useful for testing or adding Users you know exist.
$ api-admin user verify 23
You can search for users using various criteria. The search command supports partial matching by default and can search across all fields or a specific field.
Basic search (searches all fields):
$ api-admin user search "john"
Tip
contain spaces. For example, both api-admin user search john
and api-admin user search "john"
are valid.
Search in a specific field:
$ api-admin user search "john" --field first_name
The available fields are:
email
first_name
last_name
all
(default)For exact matching, use the --exact
flag:
$ api-admin user search "[email protected]" --exact
The search results will be displayed in a table showing the user's Id, Email address, First and Last name, Role, and the Verified and Banned Status.
Ban a User so they cannot access the API. You can also unban
any user by adding the -u
or --unban
flag.
$ api-admin user ban 23
or to unban:
$ api-admin user ban 23 -u
Grant admin privileges to a user. You can also remove admin status by adding the -r
or --remove
flag.
$ api-admin user admin 23
or to remove admin status:
$ api-admin user admin 23 -r
To remove a specific user from the API:
$ api-admin user delete 23
They will no longer be able to access the API, this CANNOT BE UNDONE. It's probably better to BAN a user unless you are very sure.
You can import users from a CSV file using the db seed
command:
$ api-admin db seed users.seed
This is useful for quickly populating a database with local users.
By default, the command looks for a file named users.seed
in the current directory, but you can specify a different file path as an argument.
The CSV file should have a header row with the following columns:
email
- User's email address (required)password
- User's password in PLAIN TEXT (required)first_name
- User's first name (required)last_name
- User's last name (required)role
- User's role, either 'user' or 'admin' (optional, defaults to 'user')Example users.seed
file:
email,password,first_name,last_name,role
[email protected],SecurePassword123!,John,Doe,user
[email protected],AnotherPassword456!,Jane,Smith,admin
[email protected],StrongPassword789!,Alex,Wilson,user
Important
This seed file has passwords in PLAIN TEXT and should not be added to source control, ESPECIALLY if they are stored in an external service like GitHub.
The command will:
You can use the --force
or -f
flag to skip the confirmation prompt:
$ api-admin db seed users.seed --force
All users created with this command are automatically verified and can log in immediately.
You can quickly populate your database with random test users using the db populate
command:
$ api-admin db populate
This will create 5 users by default (4 regular users and 1 admin). You can specify a different number of users with the --count
or -c
flag:
$ api-admin db populate --count 10
The command will automatically create admin users based on the total count:
For example:
All users are created with the default password Password123!
and are automatically verified. The command generates realistic email addresses using various patterns and common email domains.