diff --git a/endpoints/Add_user_organization.post.py b/endpoints/Add_user_organization.post.py index e69de29..a35ab90 100644 --- a/endpoints/Add_user_organization.post.py +++ b/endpoints/Add_user_organization.post.py @@ -0,0 +1,34 @@ +from fastapi import APIRouter, HTTPException + +organizations = [] # In-memory storage + +router = APIRouter() + +@router.post("/Add_user_organization") +async def add_user_organization( + user_id: str, + organization_id: str +): + """Add user to organization endpoint""" + org = next((o for o in organizations if o["id"] == organization_id), None) + if not org: + raise HTTPException(status_code=400, detail="Organization not found") + + if user_id in org.get("members", []): + raise HTTPException(status_code=400, detail="User already in organization") + + if "members" not in org: + org["members"] = [] + + org["members"].append(user_id) + + return { + "message": "User added to organization successfully", + "organization_id": organization_id, + "user_id": user_id, + "status": "active", + "features": { + "access_level": "member", + "added_at": "now" + } + } \ No newline at end of file