server: fixes tests

This commit is contained in:
2023-08-17 14:46:48 +02:00
parent e12f9afe7b
commit 4e9940fe29
2 changed files with 7 additions and 13 deletions

View File

@@ -3,7 +3,7 @@ from typing import Annotated
from fastapi import Depends
from fastapi.security import OAuth2PasswordBearer
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token", auto_error=False)
class UserInfo(BaseModel):
@@ -15,21 +15,12 @@ class AccessTokenInfo(BaseModel):
def authenticated(token: Annotated[str, Depends(oauth2_scheme)]):
def _authenticated():
return None
return _authenticated
return None
def current_user(token: Annotated[str, Depends(oauth2_scheme)]):
def _current_user():
return None
return _current_user
return None
def current_user_optional(token: Annotated[str, Depends(oauth2_scheme)]):
def _current_user_optional():
return None
return _current_user_optional
return None

View File

@@ -217,6 +217,9 @@ class DeletionStatus(BaseModel):
async def transcripts_list(
user: auth.UserInfo = Depends(auth.current_user),
):
if not user:
raise HTTPException(status_code=401, detail="Not authenticated")
return paginate(await transcripts_controller.get_all(user_id=user["sub"]))