We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f668ab4 commit d7e47ffCopy full SHA for d7e47ff
components/gitpod-db/src/typeorm/team-db-impl.ts
@@ -203,6 +203,12 @@ 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
+ const teamSize = await membershipRepo.count({ teamId, deleted: false });
208
+ if (teamSize <= 1) {
209
+ throw new ResponseError(ErrorCodes.BAD_REQUEST, "Cannot change role on the last remaining team member");
210
+ }
211
212
const membership = await membershipRepo.findOne({ teamId, userId, deleted: false });
213
if (!membership) {
214
throw new ResponseError(ErrorCodes.NOT_FOUND, "The user is not currently a member of this team");
0 commit comments