Fix set-active endpoint (PUT /users/:id/active) + add invite email

This commit is contained in:
inference-bot committed 2026-09-05 22:19:58 -06:00
1 parent 808357215d
commit ef467423ac
1 file changed
+14 -2
+14 -2
View File
@@ -203,14 +203,25 @@ async def cloudron_set_group(user_id: str) -> None:
async def cloudron_set_active(user_id: str, active: bool) -> None:
async with httpx.AsyncClient() as client:
r = await client.post(
f"{CLOUDRON_API}/api/v1/users/{user_id}",
r = await client.put(
f"{CLOUDRON_API}/api/v1/users/{user_id}/active",
headers=cloudron_headers(),
json={"active": active},
)
r.raise_for_status()
async def cloudron_send_invite(user_id: str, email: str) -> None:
"""Send the account-setup invite email to the member."""
async with httpx.AsyncClient() as client:
r = await client.post(
f"{CLOUDRON_API}/api/v1/users/{user_id}/send_invite_email",
headers=cloudron_headers(),
json={"email": email},
)
r.raise_for_status()
async def litellm_create_key(email: str, budget: float) -> str:
"""Create a LiteLLM virtual key for a member with a budget cap."""
async with httpx.AsyncClient() as client:
@@ -438,6 +449,7 @@ async def oauth_callback(request: Request):
await cloudron_set_active(user_id, True)
key_token = await litellm_create_key(email, MEMBER_BUDGET)
store_member(email, key_token, user_id)
await cloudron_send_invite(user_id, email)
logger.info("Provisioned member %s (user_id=%s)", email, user_id)