fix http basic requiring
All checks were successful
Build and Publish / build_and_publish (push) Successful in 22s

This commit is contained in:
Nexus 2024-07-25 23:57:48 +01:00
parent 918c797df4
commit 29838b7046
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -65,8 +65,12 @@ async def lifespan(_app: FastAPI):
)
yield
httpbasic = HTTPBasic(auto_error=False)
async def has_account(req: Request, credentials: HTTPBasicCredentials = Depends(HTTPBasic())) -> db.Account | None:
async def has_account(req: Request, credentials: HTTPBasicCredentials | None = Depends(httpbasic)) -> db.Account | None:
if os.getenv("ALLOW_ANONYMOUS", "true") == "true" and not credentials:
return
account = await db.Account.get_or_none(username=credentials.username)
if account is None:
if os.getenv("ALLOW_ANONYMOUS", "true") == "true":