Admin overview: add activated (inviteAccepted) field
This commit is contained in:
1 parent
8e4bf64199
commit
fabd5a37ae
1 file changed
+9
-3
+9
-3
@@ -1097,9 +1097,12 @@ async def admin_overview(token: str):
|
|||||||
).fetchall()
|
).fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
# Fetch Cloudron users once to map user_id → username (most provisioned
|
# Fetch Cloudron users once to map user_id → username + inviteAccepted.
|
||||||
# members have username=None, so we surface it only when it exists).
|
# username is set only after the member completes account setup (chooses a
|
||||||
|
# username + password via the setup link); inviteAccepted tracks that same
|
||||||
|
# step, so "activated" = inviteAccepted (username present).
|
||||||
usernames = {}
|
usernames = {}
|
||||||
|
invite_accepted = {}
|
||||||
try:
|
try:
|
||||||
async with httpx.AsyncClient(timeout=15.0) as client:
|
async with httpx.AsyncClient(timeout=15.0) as client:
|
||||||
r = await client.get(
|
r = await client.get(
|
||||||
@@ -1108,8 +1111,10 @@ async def admin_overview(token: str):
|
|||||||
)
|
)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
for u in r.json().get("users", []):
|
for u in r.json().get("users", []):
|
||||||
|
uid = u.get("id")
|
||||||
if u.get("username"):
|
if u.get("username"):
|
||||||
usernames[u.get("id")] = u["username"]
|
usernames[uid] = u["username"]
|
||||||
|
invite_accepted[uid] = bool(u.get("inviteAccepted"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning("admin overview: cloudron users fetch failed: %s", e)
|
logger.warning("admin overview: cloudron users fetch failed: %s", e)
|
||||||
|
|
||||||
@@ -1137,6 +1142,7 @@ async def admin_overview(token: str):
|
|||||||
{
|
{
|
||||||
"email": email,
|
"email": email,
|
||||||
"username": usernames.get(user_id),
|
"username": usernames.get(user_id),
|
||||||
|
"activated": invite_accepted.get(user_id, False),
|
||||||
"active": bool(active),
|
"active": bool(active),
|
||||||
"balance": float(balance) if balance is not None else MEMBER_BUDGET,
|
"balance": float(balance) if balance is not None else MEMBER_BUDGET,
|
||||||
"spend": spend,
|
"spend": spend,
|
||||||
|
|||||||
Reference in new issue
Block a user