diff --git a/app/main.py b/app/main.py
index 10b6daa..439a41e 100644
--- a/app/main.py
+++ b/app/main.py
@@ -201,23 +201,22 @@ 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 portal enforces the abuse rules (one guest access per inviter per 30 days,
- one per recipient ever, active-member inviter) and returns a clear
- refusal — surfaced to the operator as-is.
+ 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.
"""
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()
- inviter = (body.get("inviter") or body.get("inviter_email") or "").strip().lower()
if not email or "@" not in email:
return JSONResponse({"error": "A valid recipient email is required"}, status_code=400)
- if not inviter or "@" not in inviter:
- return JSONResponse({"error": "The inviting member's email is required"}, status_code=400)
try:
- return await portal_post("/admin/provision-guest",
- {"email": email, "name": name, "inviter": inviter})
+ return await portal_post("/admin/provision-guest", {"email": email})
except HTTPException as e:
return JSONResponse({"error": e.detail}, status_code=e.status_code)
@@ -363,8 +362,19 @@ PAGE_HTML = """
.pill.org { background: #e7edf5; color: #4a6a8a; }
.pill.grace { background: #fdf3e3; color: #a97a2a; }
.pill.guest { background: #efe7f2; color: #7a5a92; }
- #guest-group input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; width: 170px; }
- #guest-group input#guest-name { width: 120px; }
+ /* Standard guest-invite form (shared with the member dashboard): ONE field,
+ plain labels, fits a narrow frame. */
+ .guest-invite-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; margin-top: 20px; }
+ .guest-invite-title { font-size: 14px; font-weight: 700; color: var(--ink); }
+ .guest-invite-sub { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }
+ .guest-invite-form { display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
+ .guest-invite-label { font-size: 12px; font-weight: 600; color: var(--muted); }
+ .guest-invite-form input { width: 100%; min-width: 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); }
+ .guest-invite-form input:focus { outline: none; border-color: var(--green-mid); }
+ .guest-invite-btn { cursor: pointer; border: none; border-radius: 8px; background: var(--green-deep); color: #fff; font-size: 13px; font-weight: 600; padding: 10px 16px; align-self: flex-start; }
+ .guest-invite-btn:hover { background: #4e7a4d; }
+ .guest-invite-btn:disabled { opacity: 0.6; cursor: default; }
+ @media (max-width: 600px) { .guest-invite-btn { align-self: stretch; } }
/* Trends tab (charts). Colours come from the same vars as the rest of the
panel; the SVG is inline so there is no chart library and no CDN. */
.trend-controls { display: flex; gap: 22px; flex-wrap: wrap; margin: 14px 0 0; }
@@ -448,14 +458,6 @@ PAGE_HTML = """
-
- Guest access
-
-
-
-
-
- Period
@@ -483,6 +485,18 @@ PAGE_HTML = """
+
+
+
Invite a guest
+
Sends $5 of credits and 60 days of chat + dashboard access. The invitation comes from the co-op (admin) — no monthly cap.
+
+
+
+
Guests
Guest accounts — access an inviting member gave to someone outside the co-op. Not members — excluded from member counts; guest access lapses on its time box or when its credits are spent.
@@ -1210,10 +1224,10 @@ function switchView(view) {
$('tab-guestrequests').className = 'tab-btn' + (view === 'guestrequests' ? ' active' : '');
$('view-title').textContent = view === 'members' ? 'Members' : (view === 'models' ? 'Model usage' : (view === 'trends' ? 'Trends' : (view === 'money' ? 'Money' : 'Guest requests')));
// Mode groups: Balance/All-time for members; Period for models; the guest
- // action belongs to the members view too.
+ // invite form belongs to the members view too.
$('range-group').style.display = view === 'models' ? '' : 'none';
$('member-mode-group').style.display = view === 'members' ? '' : 'none';
- $('guest-group').style.display = view === 'members' ? '' : 'none';
+ $('guest-invite-section').style.display = view === 'members' ? '' : 'none';
// Trends renders on first visit only, so the panel's initial load stays fast.
if (view === 'trends') loadMetrics();
// Money renders on first visit only, same rule: one fetch, then the
@@ -1271,10 +1285,6 @@ function render() {
}
function renderMembers() {
- // Datalist for the guest form's recipient/inviter fields: member emails the
- // operator can pick from (rebuilt per render; tiny).
- const dl = document.getElementById('member-email-list');
- if (dl) dl.innerHTML = membersData.map(m => '').join('');
const rows = [...membersData].sort((a, b) => {
let va = a[memberSort.key], vb = b[memberSort.key];
if (memberSort.key === 'spend') { va = memberSpend(a); vb = memberSpend(b); }
@@ -1464,31 +1474,30 @@ async function addBalance(email) {
} catch (e) { flash(e.message, false); }
}
-// Guest action: provision a $5 guest account for a friend of a member. The
-// portal enforces the abuse rules (one guest access per inviter per 30 days, one per
-// recipient ever, inviter must be an active member) and reports a clear
-// refusal; the panel only collects the three fields.
-async function sendGuestAccess() {
+// 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.
+async function sendGuestAccess(ev) {
+ if (ev) ev.preventDefault();
const email = ($('guest-email').value || '').trim();
- const name = ($('guest-name').value || '').trim();
- const inviter = ($('guest-inviter').value || '').trim();
const btn = $('guest-send');
- if (!email || email.indexOf('@') < 1) { flash("Enter the recipient's email", false); return; }
- if (!inviter || inviter.indexOf('@') < 1) { flash("Enter the inviting member's email", false); return; }
+ 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, name, inviter })
+ body: JSON.stringify({ email })
});
const d = await r.json().catch(() => ({}));
if (!r.ok || d.error) { flash(d.error || ('Could not send guest access (' + r.status + ')'), false); return; }
- flash('Guest access sent — ' + email + ' has $5 of credits (expires in ' + (d.expires_in_days || 60) +
+ 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-name').value = '';
+ $('guest-email').value = '';
load();
} catch (e) { flash('Guest access failed: ' + e.message, false); }
- finally { btn.disabled = false; btn.textContent = 'Send guest access'; }
+ finally { btn.disabled = false; btn.textContent = 'Send invite'; }
}
// ---- Guest requests: the member self-serve trial gate ----------------------