API Reference
Auto-generated Python API documentation for the Turva backend.
Configuration
config
ConfigurationError
Bases: Exception
Raised when a configuration error occurs
Source code in src/config.py
5 6 | |
options: show_root_heading: true show_source: true
Models
User Model
models.user
User
Bases: Model, DateFieldsMixins, BaseUser
Source code in models/user.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
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
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
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
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
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