Skip to content

Commit

Permalink
Make ChangeOrgMemberRole handle missing userId
Browse files Browse the repository at this point in the history
Since ChangeOrgMemberRole is called directly from GraphQL, it's possible
it could be passed a userId that isn't in our database. Ensure that it
can't accidentally create an invalid OrgMember entry in that case.
  • Loading branch information
rmunn committed Jun 12, 2024
1 parent 4faa6df commit c9240d6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/LexBoxApi/GraphQL/OrgMutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public async Task<IQueryable<Organization>> ChangeOrgMemberRole(
NotFoundException.ThrowIfNull(org);

permissionService.AssertCanEditOrg(org);
var user = await dbContext.Users.FindAsync(userId);
NotFoundException.ThrowIfNull(user);
await UpdateOrgMemberRole(dbContext, org, role, userId);
return dbContext.Orgs.Where(o => o.Id == orgId);
}
Expand Down

0 comments on commit c9240d6

Please sign in to comment.