1- // FIXME: Update this file to be null safe and then delete the line below
2- #nullable disable
3-
4- using System . Net ;
1+ using System . Net ;
52using Bit . Api . AdminConsole . Public . Models . Request ;
63using Bit . Api . AdminConsole . Public . Models . Response ;
74using Bit . Api . Models . Public . Response ;
@@ -24,11 +21,9 @@ public class MembersController : Controller
2421 private readonly IOrganizationUserRepository _organizationUserRepository ;
2522 private readonly IGroupRepository _groupRepository ;
2623 private readonly IOrganizationService _organizationService ;
27- private readonly IUserService _userService ;
2824 private readonly ICurrentContext _currentContext ;
2925 private readonly IUpdateOrganizationUserCommand _updateOrganizationUserCommand ;
3026 private readonly IUpdateOrganizationUserGroupsCommand _updateOrganizationUserGroupsCommand ;
31- private readonly IApplicationCacheService _applicationCacheService ;
3227 private readonly IPaymentService _paymentService ;
3328 private readonly IOrganizationRepository _organizationRepository ;
3429 private readonly ITwoFactorIsEnabledQuery _twoFactorIsEnabledQuery ;
@@ -39,11 +34,9 @@ public MembersController(
3934 IOrganizationUserRepository organizationUserRepository ,
4035 IGroupRepository groupRepository ,
4136 IOrganizationService organizationService ,
42- IUserService userService ,
4337 ICurrentContext currentContext ,
4438 IUpdateOrganizationUserCommand updateOrganizationUserCommand ,
4539 IUpdateOrganizationUserGroupsCommand updateOrganizationUserGroupsCommand ,
46- IApplicationCacheService applicationCacheService ,
4740 IPaymentService paymentService ,
4841 IOrganizationRepository organizationRepository ,
4942 ITwoFactorIsEnabledQuery twoFactorIsEnabledQuery ,
@@ -53,11 +46,9 @@ public MembersController(
5346 _organizationUserRepository = organizationUserRepository ;
5447 _groupRepository = groupRepository ;
5548 _organizationService = organizationService ;
56- _userService = userService ;
5749 _currentContext = currentContext ;
5850 _updateOrganizationUserCommand = updateOrganizationUserCommand ;
5951 _updateOrganizationUserGroupsCommand = updateOrganizationUserGroupsCommand ;
60- _applicationCacheService = applicationCacheService ;
6152 _paymentService = paymentService ;
6253 _organizationRepository = organizationRepository ;
6354 _twoFactorIsEnabledQuery = twoFactorIsEnabledQuery ;
@@ -115,19 +106,18 @@ public async Task<IActionResult> GetGroupIds(Guid id)
115106 /// </summary>
116107 /// <remarks>
117108 /// Returns a list of your organization's members.
118- /// Member objects listed in this call do not include information about their associated collections.
109+ /// Member objects listed in this call include information about their associated collections.
119110 /// </remarks>
120111 [ HttpGet ]
121112 [ ProducesResponseType ( typeof ( ListResponseModel < MemberResponseModel > ) , ( int ) HttpStatusCode . OK ) ]
122113 public async Task < IActionResult > List ( )
123114 {
124- var organizationUserUserDetails = await _organizationUserRepository . GetManyDetailsByOrganizationAsync ( _currentContext . OrganizationId . Value ) ;
125- // TODO: Get all CollectionUser associations for the organization and marry them up here for the response.
115+ var organizationUserUserDetails = await _organizationUserRepository . GetManyDetailsByOrganizationAsync ( _currentContext . OrganizationId ! . Value , includeCollections : true ) ;
126116
127117 var orgUsersTwoFactorIsEnabled = await _twoFactorIsEnabledQuery . TwoFactorIsEnabledAsync ( organizationUserUserDetails ) ;
128118 var memberResponses = organizationUserUserDetails . Select ( u =>
129119 {
130- return new MemberResponseModel ( u , orgUsersTwoFactorIsEnabled . FirstOrDefault ( tuple => tuple . user == u ) . twoFactorIsEnabled , null ) ;
120+ return new MemberResponseModel ( u , orgUsersTwoFactorIsEnabled . FirstOrDefault ( tuple => tuple . user == u ) . twoFactorIsEnabled , u . Collections ) ;
131121 } ) ;
132122 var response = new ListResponseModel < MemberResponseModel > ( memberResponses ) ;
133123 return new JsonResult ( response ) ;
@@ -158,7 +148,7 @@ public async Task<IActionResult> Post([FromBody] MemberCreateRequestModel model)
158148
159149 invite . AccessSecretsManager = hasStandaloneSecretsManager ;
160150
161- var user = await _organizationService . InviteUserAsync ( _currentContext . OrganizationId . Value , null ,
151+ var user = await _organizationService . InviteUserAsync ( _currentContext . OrganizationId ! . Value , null ,
162152 systemUser : null , invite , model . ExternalId ) ;
163153 var response = new MemberResponseModel ( user , invite . Collections ) ;
164154 return new JsonResult ( response ) ;
@@ -188,12 +178,12 @@ public async Task<IActionResult> Put(Guid id, [FromBody] MemberUpdateRequestMode
188178 var updatedUser = model . ToOrganizationUser ( existingUser ) ;
189179 var associations = model . Collections ? . Select ( c => c . ToCollectionAccessSelection ( ) ) . ToList ( ) ;
190180 await _updateOrganizationUserCommand . UpdateUserAsync ( updatedUser , existingUserType , null , associations , model . Groups ) ;
191- MemberResponseModel response = null ;
181+ MemberResponseModel response ;
192182 if ( existingUser . UserId . HasValue )
193183 {
194184 var existingUserDetails = await _organizationUserRepository . GetDetailsByIdAsync ( id ) ;
195- response = new MemberResponseModel ( existingUserDetails ,
196- await _twoFactorIsEnabledQuery . TwoFactorIsEnabledAsync ( existingUserDetails ) , associations ) ;
185+ response = new MemberResponseModel ( existingUserDetails ! ,
186+ await _twoFactorIsEnabledQuery . TwoFactorIsEnabledAsync ( existingUserDetails ! ) , associations ) ;
197187 }
198188 else
199189 {
@@ -242,7 +232,7 @@ public async Task<IActionResult> Remove(Guid id)
242232 {
243233 return new NotFoundResult ( ) ;
244234 }
245- await _removeOrganizationUserCommand . RemoveUserAsync ( _currentContext . OrganizationId . Value , id , null ) ;
235+ await _removeOrganizationUserCommand . RemoveUserAsync ( _currentContext . OrganizationId ! . Value , id , null ) ;
246236 return new OkResult ( ) ;
247237 }
248238
@@ -264,7 +254,7 @@ public async Task<IActionResult> PostReinvite(Guid id)
264254 {
265255 return new NotFoundResult ( ) ;
266256 }
267- await _resendOrganizationInviteCommand . ResendInviteAsync ( _currentContext . OrganizationId . Value , null , id ) ;
257+ await _resendOrganizationInviteCommand . ResendInviteAsync ( _currentContext . OrganizationId ! . Value , null , id ) ;
268258 return new OkResult ( ) ;
269259 }
270260}
0 commit comments