File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
components/gitpod-db/src/typeorm Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,18 @@ export class TeamDBImpl implements TeamDB {
203
203
throw new ResponseError ( ErrorCodes . NOT_FOUND , "A team with this ID could not be found" ) ;
204
204
}
205
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
+
206
218
const membership = await membershipRepo . findOne ( { teamId, userId, deleted : false } ) ;
207
219
if ( ! membership ) {
208
220
throw new ResponseError ( ErrorCodes . NOT_FOUND , "The user is not currently a member of this team" ) ;
You can’t perform that action at this time.
0 commit comments