Fix #391: put user creation logic in a importable function

This commit is contained in:
François Voron
2020-11-22 09:57:03 +01:00
parent e69a124084
commit 435f29331a
8 changed files with 128 additions and 20 deletions

22
docs/usage/helpers.md Normal file
View File

@ -0,0 +1,22 @@
# Helpers
## Create user
**FastAPI Users** provides a helper function to easily create a user programmatically. They are available from your `FastAPIUsers` instance.
```py
regular_user = await fastapi_users.create_user(
UserCreate(
email="king.arthur@camelot.bt",
password="guinevere",
)
)
superuser = await fastapi_users.create_user(
UserCreate(
email="king.arthur@camelot.bt",
password="guinevere",
is_superuser=True,
)
)
```