${JSON.stringify(data, null, 4)}
- `;
+ render(node, 'User deleted successfully', JSON.stringify(data, null, 4));
},
(err: Error | ApiError | string) => {
const message =
err instanceof Error ? err.message : typeof err === 'object' && err !== null && err.error ? err.error : err;
console.error(err);
- node.innerHTML = `
- ${message}
- `;
+ render(node, 'Something went wrong', String(message));
}
);
});
}
+function render(node: HTMLElement, heading: string, details: string): void {
+ const title = document.createElement('h3');
+ title.textContent = heading;
+
+ const body = document.createElement('pre');
+ body.textContent = details;
+
+ node.replaceChildren(title, body);
+}
+
function handleNotAuthorizedError(node: HTMLElement): void {
- node.innerHTML = `
- Sign in as admin to delete user information
- `; + // the session has to belong to the site the request came from, so the admin signs in through the + // comments on that site rather than the demo page, which is fixed to a site of its own + render( + node, + 'You are not logged in', + `Sign in as admin to the comments on site "${siteId}", then open this link again to delete user information.` + ); } diff --git a/site/content/docs/contributing/api/index.md b/site/content/docs/contributing/api/index.md index f11083109b..53b005c21c 100644 --- a/site/content/docs/contributing/api/index.md +++ b/site/content/docs/contributing/api/index.md @@ -231,6 +231,6 @@ http://oldsite.com/from-old-page/1 https://newsite.com/to-new-page/1 - `DELETE /api/v1/admin/user/{userid}?site=site-id` - delete the user's comments and stored details; succeeds even if the user has no comments or is already absent - `PUT /api/v1/admin/readonly?site=site-id&url=post-url&ro=1` - set read-only status - `PUT /api/v1/admin/verify/{userid}?site=site-id&verified=1` - set verified status -- `GET /api/v1/admin/deleteme?token=token` - process a user's deleteme request; already-deleted or dataless users return success (idempotent) +- `GET /api/v1/admin/deleteme?site=site-id&token=token` - process a user's deleteme request; already-deleted or dataless users return success (idempotent) _all admin calls require auth and admin privilege_