Fix set-active endpoint (PUT /users/:id/active) + add invite email
This commit is contained in:
1 parent
808357215d
commit
ef467423ac
1 file changed
+14
-2
+14
-2
@@ -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 def cloudron_set_active(user_id: str, active: bool) -> None:
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
r = await client.post(
|
r = await client.put(
|
||||||
f"{CLOUDRON_API}/api/v1/users/{user_id}",
|
f"{CLOUDRON_API}/api/v1/users/{user_id}/active",
|
||||||
headers=cloudron_headers(),
|
headers=cloudron_headers(),
|
||||||
json={"active": active},
|
json={"active": active},
|
||||||
)
|
)
|
||||||
r.raise_for_status()
|
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:
|
async def litellm_create_key(email: str, budget: float) -> str:
|
||||||
"""Create a LiteLLM virtual key for a member with a budget cap."""
|
"""Create a LiteLLM virtual key for a member with a budget cap."""
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
@@ -438,6 +449,7 @@ async def oauth_callback(request: Request):
|
|||||||
await cloudron_set_active(user_id, True)
|
await cloudron_set_active(user_id, True)
|
||||||
key_token = await litellm_create_key(email, MEMBER_BUDGET)
|
key_token = await litellm_create_key(email, MEMBER_BUDGET)
|
||||||
store_member(email, key_token, user_id)
|
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)
|
logger.info("Provisioned member %s (user_id=%s)", email, user_id)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user