API Reference¶
Auto-generated Python API documentation for the Turva backend.
Configuration¶
config
¶
options: show_root_heading: true show_source: true
Models¶
User Model¶
models.user
¶
User
¶
Bases: Model, DateFieldsMixins, BaseUser
Source code in models/user.py
get_verification_token()
async
¶
Returns the user's email verification token.
If the user is already verified, an error is raised. If the token has expired, a new token is generated, saved and returned.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The email verification token. |
Source code in models/user.py
has_verification_token_expired()
async
¶
Checks if the user's email verification token has expired.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the token has expired, False otherwise. |
Source code in models/user.py
options: show_root_heading: true members: - User
Session Model¶
models.session
¶
options: show_root_heading: true members: - Session
Authentication¶
authentication.middleware
¶
TurvaAuthenticationBackend
¶
Bases: AuthenticationBackend
This middleware does behind the scenes stuff to maintain the user's session.
It checks that the user's session is valid and that the user is active. If the session is invalid or the user is not active, the user's session is deleted, logging them out.
This also handles updating the user's session expiry on each request.
Source code in authentication/middleware.py
options: show_root_heading: true
Endpoints¶
endpoints
¶
In this module, there are a series of other folders. Each of those folders contain files that are used to create the endpoints for the API.
This script will import all of these files and create the endpoints for the API, using the name of
each folder as the endpoint prefix (/
It will also support nesting folders and creating the route accordingly.
For example, if you have the following folder structure: ``` endpoints ├── auth │ ├── login.py │ ├── register.py | ├── test | ├── dothing.py
You will have the following endpoints: /auth/login /auth/register /auth/test/dothing
options: show_root_heading: true