Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3373341
D8200.id27722.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D8200.id27722.diff
View Options
diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js
--- a/keyserver/src/updaters/thread-updaters.js
+++ b/keyserver/src/updaters/thread-updaters.js
@@ -76,13 +76,14 @@
throw new ServerError('not_logged_in');
}
- const [memberIDs, hasPermission] = await Promise.all([
+ const [memberIDs, hasPermission, fetchThreadResult] = await Promise.all([
verifyUserIDs(request.memberIDs),
checkThreadPermission(
viewer,
request.threadID,
threadPermissions.CHANGE_ROLE,
),
+ fetchThreadInfos(viewer, SQL`t.id = ${request.threadID}`),
]);
if (memberIDs.length === 0) {
throw new ServerError('invalid_parameters');
@@ -91,6 +92,22 @@
throw new ServerError('invalid_credentials');
}
+ const threadInfo = fetchThreadResult.threadInfos[request.threadID];
+
+ const memberRole = threadInfo.members.find(
+ member => member.id === request.memberIDs[0],
+ )?.role;
+
+ const memberRoleCount = threadInfo.members.filter(
+ member => member.role === memberRole,
+ ).length;
+ const memberRoleName = memberRole && threadInfo.roles[memberRole].name;
+
+ // Prevent the last community admin from having their role changed
+ if (memberRoleName === 'Admins' && memberRoleCount === 1) {
+ throw new ServerError('invalid_parameters');
+ }
+
const query = SQL`
SELECT user, role
FROM memberships
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 9:07 AM (20 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2589981
Default Alt Text
D8200.id27722.diff (1 KB)
Attached To
Mode
D8200: [keyserver] Prevent the only admin role from being changed on the keyserver
Attached
Detach File
Event Timeline
Log In to Comment