34 lines
950 B
Python
34 lines
950 B
Python
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"
|
|
}
|
|
} |