auth
This module defines a router for the api that is dedicated to authentication.
login
login(user_credentials: Annotated[OAuth2PasswordRequestForm, Depends()], session: Annotated[Session, Depends(database.get_session)])
Endpoint for user login. Returns a JWT token upon successful authentication.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_credentials |
OAuth2PasswordRequestForm
|
The user's credentials (username and password) obtained from the request. |
required |
session |
Session
|
The session to interact with the database. |
required |
Raises:
Type | Description |
---|---|
HTTPException
|
If the credentials are invalid, raises status code 403 (FORBIDDEN) with appropriate detail. |
Returns:
Type | Description |
---|---|
Token
|
The JWT token and its type upon successful authentication. |
Source code in api/routers/auth.py
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 |
|