Allow anonymous creation properly
All checks were successful
Build and Publish / build_and_publish (push) Successful in 1m6s
All checks were successful
Build and Publish / build_and_publish (push) Successful in 1m6s
This commit is contained in:
parent
7eee976692
commit
918c797df4
1 changed files with 3 additions and 1 deletions
|
@ -66,9 +66,11 @@ async def lifespan(_app: FastAPI):
|
|||
yield
|
||||
|
||||
|
||||
async def has_account(req: Request, credentials: HTTPBasicCredentials = Depends(HTTPBasic())) -> db.Account:
|
||||
async def has_account(req: Request, credentials: HTTPBasicCredentials = Depends(HTTPBasic())) -> db.Account | None:
|
||||
account = await db.Account.get_or_none(username=credentials.username)
|
||||
if account is None:
|
||||
if os.getenv("ALLOW_ANONYMOUS", "true") == "true":
|
||||
return
|
||||
raise HTTPException(status_code=401, detail="Invalid credentials", headers={"WWW-Authenticate": "Basic"})
|
||||
ph = PasswordHasher()
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue