Skip to content

Commit d7e47ff

Browse files
committed
[server] Prevent changing role for teams of size 1
1 parent f668ab4 commit d7e47ff

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: components/gitpod-db/src/typeorm/team-db-impl.ts

+6
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ export class TeamDBImpl implements TeamDB {
203203
throw new ResponseError(ErrorCodes.NOT_FOUND, "A team with this ID could not be found");
204204
}
205205
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+
206212
const membership = await membershipRepo.findOne({ teamId, userId, deleted: false });
207213
if (!membership) {
208214
throw new ResponseError(ErrorCodes.NOT_FOUND, "The user is not currently a member of this team");

0 commit comments

Comments
 (0)