Share one user form, add user photos and Revoke, confirm every form

- Settings > Users uses the people UserForm (useFormInit) instead of its
  own copy; it saves in one request through users/save-user, which now
  takes an optional profile photo (setUserProfileImage)
- Revoke action on user rows adds the revoked type, as the edit form would
- Every admin form asks for confirmation before it saves

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-19 11:03:57 +01:00
co-authored by Claude Opus 5.5
parent c44048dbab
commit 4dd34ed251
35 changed files with 352 additions and 535 deletions
@@ -0,0 +1,36 @@
import bufferFromBase64 from "@/src/utils/buffer-from-base-64";
import deleteMedia from "../media/delete-media";
import uploadAndRecordMedia from "./media/upload-and-record-media";
type Params = {
user_id: number;
/**
* The new photo as a base64 data URL.
*/
data_url: string;
};
/**
* Replaces a user's profile photo: their old one is deleted, then this one
* stored as their primary `user-profile-image`. The caller checks the actor
* may update this user.
*/
export default async function setUserProfileImage({ user_id, data_url }: Params) {
const { buffer, ext } = await bufferFromBase64(data_url);
await deleteMedia({ media_paradigm: "user-profile-image", user_id, can_delete_all_media: true });
const res = await uploadAndRecordMedia({
data: buffer,
media_paradigms: ["user-profile-image"],
media_type: "image",
is_primary: true,
update_on_duplicate: true,
media_mime_type: ext,
user: { id: user_id },
});
if (!res.success) {
throw new Error(`Couldn't save the photo: ${res.msg}`);
}
}