mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-26 04:25:46 +08:00
Fix #391: put user creation logic in a importable function
This commit is contained in:
22
docs/usage/helpers.md
Normal file
22
docs/usage/helpers.md
Normal 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,
|
||||
)
|
||||
)
|
||||
```
|
Reference in New Issue
Block a user