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 - - - - - -