fix: authorize coauthors by stable GitHub identity

This commit is contained in:
tdurieux
2026-09-06 09:17:01 +02:00
parent 8ec656c201
commit 2af66cd1b6
3 changed files with 28 additions and 6 deletions
+6 -3
View File
@@ -817,9 +817,12 @@ router.delete(
const user = await getUser(req);
const target = req.params.username;
const isOwner = repo.owner.id === user.model.id;
const isSelf =
!!user.username &&
user.username.toLowerCase() === target.toLowerCase();
const coauthor = (repo.model.coauthors || []).find(
(c) => c.username.toLowerCase() === target.toLowerCase()
);
const isSelf = coauthor?.githubId
? coauthor.githubId === user.model.externalIDs?.github
: !!user.username && user.username.toLowerCase() === target.toLowerCase();
if (!isOwner && !isSelf && !user.isAdmin) {
throw new AnonymousError("not_authorized", { httpStatus: 401 });
}