Fix #14: add /me route

This commit is contained in:
François Voron
2019-10-20 09:30:26 +02:00
parent 8d65a11a4f
commit 1996ed69ea
3 changed files with 58 additions and 5 deletions

View File

@@ -2,7 +2,9 @@
You'll find here the routes exposed by **FastAPI Users**. Note that you can also review them through the [interactive API docs](https://fastapi.tiangolo.com/tutorial/first-steps/#interactive-api-docs).
## `POST /register`
## Unauthenticated
### `POST /register`
Register a new user.
@@ -29,7 +31,7 @@ Register a new user.
!!! fail "`400 Bad Request`"
A user already exists with this email.
## `POST /login`
### `POST /login`
Login a user.
@@ -50,7 +52,7 @@ Login a user.
!!! fail "`400 Bad Request`"
Bad credentials or the user is inactive.
## `POST /forgot-password`
### `POST /forgot-password`
Request a reset password procedure. Will generate a temporary token and call the defined `on_after_forgot_password` if the user exists.
@@ -65,7 +67,7 @@ To prevent malicious users from guessing existing users in your databse, the rou
!!! success "`202 Accepted`"
## `POST /reset-password`
### `POST /reset-password`
Reset a password. Requires the token generated by the `/forgot-password` route.
@@ -77,9 +79,28 @@ Reset a password. Requires the token generated by the `/forgot-password` route.
}
```
!!! success "`200 Accepted`"
!!! success "`200 OK`"
!!! fail "`422 Validation Error`"
!!! fail "`400 Bad Request`"
Bad or expired token.
## Authenticated
### `GET /me`
Return the current authenticated active user.
!!! success "`200 OK`"
```json
{
"id": "57cbb51a-ab71-4009-8802-3f54b4f2e23",
"email": "king.arthur@camelot.bt",
"is_active": true,
"is_superuser": false
}
```
!!! fail "`401 Unauthorized`"
Missing token or inactive user.