We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 542e7c9 commit f7f90a0Copy full SHA for f7f90a0
components/gitpod-db/src/typeorm/team-db-impl.ts
@@ -203,6 +203,18 @@ export class TeamDBImpl implements TeamDB {
203
throw new ResponseError(ErrorCodes.NOT_FOUND, "A team with this ID could not be found");
204
}
205
const membershipRepo = await this.getMembershipRepo();
206
+
207
+ if (role != "owner") {
208
+ const ownerCount = await membershipRepo.count({
209
+ teamId,
210
+ role: "owner",
211
+ deleted: false,
212
+ });
213
+ if (ownerCount <= 1) {
214
+ throw new ResponseError(ErrorCodes.CONFLICT, "Team must retain at least one owner");
215
+ }
216
217
218
const membership = await membershipRepo.findOne({ teamId, userId, deleted: false });
219
if (!membership) {
220
throw new ResponseError(ErrorCodes.NOT_FOUND, "The user is not currently a member of this team");
0 commit comments