Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
🐛 Check for single member deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Oct 3, 2019
1 parent 785befc commit d1f2cf7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "staart-manager",
"version": "1.1.38",
"version": "1.1.39",
"main": "index.js",
"repository": "[email protected]:AnandChowdhary/staart.git",
"author": "Anand Chowdhary <[email protected]>",
Expand Down Expand Up @@ -147,5 +147,5 @@
"setup"
],
"snyk": true,
"staart-version": "1.1.38"
"staart-version": "1.1.39"
}
4 changes: 4 additions & 0 deletions src/crud/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,10 @@ export const deleteOrganizationMembership = async (
organizationId: string,
id: string
) => {
// Check if there's only one member in this team
const members = await getOrganizationMemberships(organizationId);
if (members && members.data && members.length === 1)
throw new Error(ErrorCode.CANNOT_DELETE_SOLE_MEMBER);
const membershipDetails = await getOrganizationMembership(organizationId, id);
if (membershipDetails.id)
deleteItemFromCache(
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export enum ErrorCode {
UNVERIFIED_EMAIL = "401/unverified-email",
GOOGLE_AUTH_ERROR = "401/google-auth-error",
UNAPPROVED_LOCATION = "401/unapproved-location",
CANNOT_DELETE_SOLE_MEMBER = "400/cannot-delete-sole-member",
CANNOT_DELETE_SOLE_OWNER = "400/cannot-delete-sole-owner",
CANNOT_UPDATE_SOLE_OWNER = "400/cannot-update-sole-owner",
USER_IS_MEMBER_ALREADY = "400/user-is-member-already",
Expand Down

0 comments on commit d1f2cf7

Please sign in to comment.