Skip to content
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

feat: ensure at least one owner on remove user/group access #5085

Merged
merged 9 commits into from
Oct 19, 2023

Conversation

gastonfournier
Copy link
Contributor

@gastonfournier gastonfournier commented Oct 18, 2023

About the changes

This makes sure that projects have at least one owner, either a group or a user. This is to prevent accidentally losing access to a project.

We check this when removing a user/group or when changing the role of a user/group

Note: We can still leave a group empty as the only owner of the project, but that's okay because we can still add more users to the group

@vercel
Copy link

vercel bot commented Oct 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Oct 19, 2023 0:09am
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Visit Preview Oct 19, 2023 0:09am

@gastonfournier gastonfournier marked this pull request as ready for review October 18, 2023 16:09
@gastonfournier gastonfournier changed the title feat: Ensure at least one owner on remove user/group access feat: ensure at least one owner on remove user/group access Oct 18, 2023
Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this wants a test. I'm guessing this originally regressed because there wasn't one

@@ -491,31 +499,6 @@ test('should remove user from the project', async () => {
expect(memberUsers).toHaveLength(0);
});

test('should not remove user from the project', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to line 1006

Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gastonfournier gastonfournier merged commit 3d9f31f into main Oct 19, 2023
7 checks passed
@gastonfournier gastonfournier deleted the ensure-projects-have-owners branch October 19, 2023 12:15
@@ -508,6 +500,11 @@ export default class ProjectService {
userId,
);

const ownerRole = await this.accessService.getRoleByName(
RoleName.OWNER,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be a bug since we're getting a role for the owner not the user we're deleting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants