chore: use HTTPStatus for ip middleware (#2792)

This commit is contained in:
dni ⚡ 2024-12-09 11:44:01 +01:00 committed by GitHub
parent 4b63d0924e
commit f5f43e7668
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -230,7 +230,7 @@ def add_ip_block_middleware(app: FastAPI):
async def block_allow_ip_middleware(request: Request, call_next):
if not request.client:
return JSONResponse(
status_code=403, # Forbidden
status_code=HTTPStatus.FORBIDDEN,
content={"detail": "No request client"},
)
if (
@ -238,7 +238,7 @@ def add_ip_block_middleware(app: FastAPI):
and request.client.host not in settings.lnbits_allowed_ips
):
return JSONResponse(
status_code=403, # Forbidden
status_code=HTTPStatus.FORBIDDEN,
content={"detail": "IP is blocked"},
)
return await call_next(request)