diff --git a/backend/app/auth.py b/backend/app/auth.py index 464566a..6862643 100644 --- a/backend/app/auth.py +++ b/backend/app/auth.py @@ -51,3 +51,15 @@ def get_current_user( if user is None or not user.is_active: raise credentials_exception return user + + +def get_optional_user( + access_token: Optional[str] = Cookie(default=None), + db: Session = Depends(get_db), +) -> Optional[models.User]: + if not access_token: + return None + try: + return get_current_user(access_token=access_token, db=db) + except HTTPException: + return None