fix(backend): Refactor OIDC callback and auth dependency to correctly handle cookies and prefix all API routes with /api/v1.
This commit is contained in:
@@ -25,9 +25,8 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="api/v1/auth/login", auto_error=Fa
|
||||
|
||||
async def get_current_user(request: Request, token: str = Depends(oauth2_scheme)) -> User:
|
||||
"""Dependency to get the current authenticated user from the JWT token (cookie or header)."""
|
||||
# Try getting token from cookie first
|
||||
if not token:
|
||||
token = request.cookies.get("access_token")
|
||||
# Prioritize cookie, fallback to header
|
||||
token = request.cookies.get("access_token") or token
|
||||
|
||||
credentials_exception = HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
|
||||
Reference in New Issue
Block a user