Third audit: security fixes and server-side scalability
Security: - docx unzip reads each part once (a repeated entry was a zip bomb) - request files must be named for their type (no PDF named .html) - team roster hidden when its organization is unpublished - /people?ids= hides draft organizations, takes 200 ids - v_events takes the first published host and reads event_hosts directly (migration 059, plus an index on person_awards.event_id) - group accounts refused while access groups are off; group sync can't undo a superadmin's disable - 64 KB body limit on login, feedback and csp-report - Drive pick-up races no longer 500; random upload boundary Scalability: - /events filters by scope, host, status and type on the server; Home no longer prefetches every event - /organizations leaves out bodies and leadership; the map's group panel fetches its own - admin lists page with Show more and a real count - content request record search and the newsletter's post list ask the server Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0bb4b8685f
commit
f99010252f
18 changed files with 229 additions and 96 deletions
|
|
@ -28,6 +28,8 @@ export default function EntityList() {
|
|||
|
||||
const [params, setParams] = useSearchParams();
|
||||
const [rows, setRows] = useState<any[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loadingMore, setLoadingMore] = useState(false);
|
||||
const [options, setOptions] = useState<any>({});
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<any>(null);
|
||||
|
|
@ -53,6 +55,7 @@ export default function EntityList() {
|
|||
get("/admin/options", { ttl: 60_000 }),
|
||||
]);
|
||||
setRows(list.rows);
|
||||
setTotal(list.total);
|
||||
setOptions(opts.options);
|
||||
} catch (err) {
|
||||
if (isUnauthorized(err)) return navigate("/admin/login", { replace: true });
|
||||
|
|
@ -66,6 +69,22 @@ export default function EntityList() {
|
|||
load();
|
||||
}, [load]);
|
||||
|
||||
// The server sends a page at a time; the next one goes under it.
|
||||
async function loadMore() {
|
||||
setLoadingMore(true);
|
||||
try {
|
||||
const next = new URLSearchParams(params);
|
||||
next.set("offset", String(rows.length));
|
||||
const list = await get(`/admin/${manifest.key}?${next}`, { ttl: 0 });
|
||||
setRows((current) => [...current, ...list.rows]);
|
||||
setTotal(list.total);
|
||||
} catch (err) {
|
||||
setError(err instanceof ApiError ? err.message : "Couldn't reach the server.");
|
||||
} finally {
|
||||
setLoadingMore(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!manifest) {
|
||||
return <p className="text-muted">No such thing to edit.</p>;
|
||||
}
|
||||
|
|
@ -211,6 +230,22 @@ export default function EntityList() {
|
|||
)}
|
||||
{loading && <p className="px-4 py-8 text-center text-muted">Loading…</p>}
|
||||
</div>
|
||||
|
||||
{!loading && rows.length < total && (
|
||||
<div className="mt-4 flex items-center gap-4">
|
||||
<button
|
||||
type="button"
|
||||
onClick={loadMore}
|
||||
disabled={loadingMore}
|
||||
className="btn border border-muted/25 px-4 py-1.5 text-sm text-muted hover:border-brand/50 disabled:opacity-60"
|
||||
>
|
||||
{loadingMore ? "Loading…" : "Show more"}
|
||||
</button>
|
||||
<p className="text-sm text-muted">
|
||||
{rows.length} of {total}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue