mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-16 03:35:38 -04:00
🐛 Use 401 status code in security classes when credentials are missing (#13786)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
@@ -60,7 +60,7 @@ async def get_current_user(token: str = Depends(oauth2_scheme)):
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Invalid authentication credentials",
|
||||
detail="Not authenticated",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
return user
|
||||
|
||||
Reference in New Issue
Block a user