Skip to content

Commit af7cdb2

Browse files
committed
fix: Update project state logic to correctly handle user roles and deactivation
Signed-off-by: Harsh <harshmastic@gmail.com>
1 parent 82fb2e5 commit af7cdb2

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

chaoscenter/authentication/pkg/project/repository.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,19 @@ func (r repository) UpdateProjectState(ctx context.Context, userID string, deact
365365
{"members", bson.D{
366366
{"$elemMatch", bson.D{
367367
{"user_id", userID},
368-
{"role", bson.D{
369-
{"$eq", entities.RoleOwner},
368+
{"role", entities.RoleOwner},
369+
}},
370+
}},
371+
{"members", bson.D{
372+
{"$not", bson.D{
373+
{"$elemMatch", bson.D{
374+
{"user_id", bson.D{{"$ne", userID}}},
375+
{"role", entities.RoleOwner},
376+
{"deactivated_at", 0},
370377
}},
371378
}},
372-
}}}
379+
}},
380+
}
373381

374382
update = bson.D{
375383
{"$set", bson.D{

0 commit comments

Comments
 (0)