-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[backend] Workspace should have at least one valid admin (#3922) #4014
Conversation
f420a0f
to
36bbc26
Compare
Comment: If a user is deleted and he is the only admin of a workspace, the workspace will be unadministrable. This is a more global problem, that will be resolved in a future issue: #4026 |
Behaviour tested, code checked, PR approved! |
.map((e) => e.id); | ||
if (adminIds.includes(MEMBER_ACCESS_ALL)) { // everyone is admin | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a condition here that checks that there is at least one member with admin right, before trying to resolve the admin ids, otherwise return false
like this :
if (adminIds.length == 0) {
return false
}
It's the condition we had before.
const userIds = adminIds | ||
.filter((id) => !groups.map((o) => o.id).includes(id) | ||
&& !organizations.map((o) => o.id).includes(id)) | ||
.concat(groupsMembersIds, organizationsMembersIds); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groups.map((o) => o.id) and organizations.map((o) => o.id) are done inside the filter, maybe we could extract it before ? have organizationIds and groupIds, then use the include ?
Github issue: #3922
demo: see link in Teams