routes.users#
Module Contents#
Functions#
Endpoint to upload and update the user’s avatar. |
|
Endpoint to retrieve the information of the currently authenticated user. |
|
Endpoint to retrieve the profile information of a specific user by username. |
|
Endpoint to update the profile of the currently authenticated user. |
|
Endpoint to ban a user by the admin. |
Data#
API#
- routes.users.router = 'APIRouter(...)'#
- async routes.users.get_user_avatar(file: fastapi.UploadFile = File(), user: src.entity.models.User = Depends(auth_service.get_current_user), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to upload and update the user’s avatar.
- Parameters:
file (UploadFile) – The avatar image file to be uploaded.
user (User) – Current authenticated user (dependency injection).
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
The updated user information.
- Return type:
- async routes.users.get_current_user(user: src.entity.models.User = Depends(auth_service.get_current_user), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to retrieve the information of the currently authenticated user.
- Parameters:
user (User) – Current authenticated user (dependency injection).
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
The information of the currently authenticated user.
- Return type:
- async routes.users.get_user_profile(username: str, db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to retrieve the profile information of a specific user by username.
- Parameters:
username (str) – Username of the user to be retrieved.
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
The profile information of the specified user.
- Return type:
- Raises:
HTTPException – If the user is not found.
- async routes.users.update_own_profile(user_update: src.schemas.users.UserUpdate, user: src.entity.models.User = Depends(auth_service.get_current_user), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to update the profile of the currently authenticated user.
- Parameters:
user_update (UserUpdate) – UserUpdate instance containing the updated user information.
user (User) – Current authenticated user (dependency injection).
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Returns:
The updated user information.
- Return type:
- async routes.users.ban_user(username: str, current_user: src.entity.models.User = Depends(auth_service.get_current_user), db: sqlalchemy.ext.asyncio.AsyncSession = Depends(get_db))#
Endpoint to ban a user by the admin.
- Parameters:
username (str) – Username of the user to be banned.
current_user (User) – Current authenticated user (dependency injection).
db (AsyncSession) – Asynchronous SQLAlchemy session (dependency injection).
- Raises:
HTTPException – If the current user is not an admin or if the user to be banned is not found.
- Returns:
A message indicating the success of the operation.
- Return type:
dict