INNER CODE UNIT · Python

get_current_user

hunvreus/devpush · app/dependencies.py:117

async def get_current_user(
    request: Request,
    db: AsyncSession = Depends(get_db),
    settings: Settings = Depends(get_settings),
    redirect_on_fail: bool = True,
) -> User:
    """Get the current user object, redirect to login if not authenticated."""
    session = request.cookies.get("auth_token")
    if not session:
        if redirect_on_fail:
            raise HTTPException(
                status.HTTP_303_SEE_OTHER,
                headers={
                    "Location": "/auth/login",
                    "Set-Cookie": _clear_auth_cookie_header(settings),
                },
                detail="Authentication required",
            )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…