fix(types): sanitizar extraccion de payload y tipado estricto en buildings y reservations
This commit is contained in:
@@ -118,3 +118,18 @@ def require_roles(allowed_roles: List[str]) -> Callable:
|
||||
)
|
||||
|
||||
return role_dependency
|
||||
|
||||
|
||||
async def get_request_payload(request: Request) -> dict[str, Any]:
|
||||
"""Extrae el cuerpo JSON o formulario multiparte sanitizado como diccionario de Python."""
|
||||
try:
|
||||
body = await request.json()
|
||||
if isinstance(body, dict):
|
||||
return body
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
form = await request.form()
|
||||
return {str(k): str(v) for k, v in form.items()}
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user