From 575338a577654953e4441bf708ebf61ed2967298 Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Sun, 8 Nov 2026 02:57:28 +0000 Subject: [PATCH] Guest-invite form: keep a name field, optional and clearly labelled Final operator preference: the standard form is the guest's email (required) plus an OPTIONAL display name, labelled 'Their name (optional)'. The name passes through to provisioning as the initial display name (the Cloudron path fills only empty names and never overwrites one the guest sets at setup); an empty name is never derived from the email. --- app/main.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/app/main.py b/app/main.py index 439a41e..2c029eb 100644 --- a/app/main.py +++ b/app/main.py @@ -201,22 +201,24 @@ async def api_set_credits(request: Request): async def api_provision_guest(request: Request): """Provision a guest account via the portal's /admin/provision-guest. - The standard guest-invite form: ONE field (the guest's email). No name is - collected and none is derived — the guest chooses their own display name - and username during Cloudron account setup, and the invitation greets - neutrally. The portal records the co-op's ADMIN account as the inviter — - admins are not bound by the member's one-per-30-days cap, and the - recipient-side guards (one guest per recipient ever, no existing portal - row) still run there. A refusal is surfaced to the operator as-is. + The standard guest-invite form: the guest's email (required) plus an + OPTIONAL display name — passed through as the guest's initial display + name; when empty, nothing is derived (the guest chooses their own name + at Cloudron setup and the invitation greets neutrally). The portal + records the co-op's ADMIN account as the inviter — admins are not bound + by the member's one-per-30-days cap, and the recipient-side guards (one + guest per recipient ever, no existing portal row) still run there. A + refusal is surfaced to the operator as-is. """ if not is_admin(request): return JSONResponse({"error": "forbidden"}, status_code=403) body = await request.json() email = (body.get("email") or "").strip().lower() + name = (body.get("name") or "").strip() if not email or "@" not in email: return JSONResponse({"error": "A valid recipient email is required"}, status_code=400) try: - return await portal_post("/admin/provision-guest", {"email": email}) + return await portal_post("/admin/provision-guest", {"email": email, "name": name}) except HTTPException as e: return JSONResponse({"error": e.detail}, status_code=e.status_code) @@ -492,6 +494,8 @@ PAGE_HTML = """
+ +
@@ -1475,26 +1479,29 @@ async function addBalance(email) { } // Guest action: provision a $5 guest account — the standard guest-invite form -// (ONE field: the guest's email). The inviter is always the co-op's ADMIN -// account, recorded by the portal; admins have no monthly cap. The portal -// enforces the recipient-side guards (one guest per recipient ever, no -// existing portal row) and reports a clear refusal. +// (the guest's email, required, plus an OPTIONAL display name; if left empty +// the guest sets their own at Cloudron setup and the invitation greets +// neutrally). The inviter is always the co-op's ADMIN account, recorded by +// the portal; admins have no monthly cap. The portal enforces the +// recipient-side guards (one guest per recipient ever, no existing portal +// row) and reports a clear refusal. async function sendGuestAccess(ev) { if (ev) ev.preventDefault(); const email = ($('guest-email').value || '').trim(); + const name = ($('guest-name').value || '').trim(); const btn = $('guest-send'); if (!email || email.indexOf('@') < 1) { flash("Enter the guest's email", false); return; } btn.disabled = true; btn.textContent = "Sending…"; try { const r = await fetch('/api/provision-guest', { method: 'POST', headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({ email }) + body: JSON.stringify({ email, name }) }); const d = await r.json().catch(() => ({})); if (!r.ok || d.error) { flash(d.error || ('Could not send guest access (' + r.status + ')'), false); return; } flash('Invite sent — ' + email + ' has $5 of credits (expires in ' + (d.expires_in_days || 60) + ' days). The welcome email is on its way.', true); - $('guest-email').value = ''; + $('guest-email').value = ''; $('guest-name').value = ''; load(); } catch (e) { flash('Guest access failed: ' + e.message, false); } finally { btn.disabled = false; btn.textContent = 'Send invite'; }