from fastapi import Depends, HTTPException, status from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer from app.core.security import decode_token bearer = HTTPBearer() def get_current_user(credentials: HTTPAuthorizationCredentials = Depends(bearer)) -> str: username = decode_token(credentials.credentials) if not username: raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token") return username