Skip to content

Commit dcc2cc7

Browse files
committed
[PM-15621] Ready for app code review.
1 parent 38405ef commit dcc2cc7

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Api/AdminConsole/Controllers/OrganizationUsersController.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using Bit.Core.Exceptions;
2424
using Bit.Core.Models.Business;
2525
using Bit.Core.Models.Commands;
26+
using Bit.Core.Models.Data.Organizations;
2627
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
2728
using Bit.Core.OrganizationFeatures.OrganizationSubscriptions.Interface;
2829
using Bit.Core.OrganizationFeatures.OrganizationUsers.Interfaces;
@@ -595,6 +596,12 @@ public async Task<IActionResult> DeleteAccount(Guid orgId, Guid id)
595596

596597
var result = await _deleteManagedOrganizationUserAccountCommand.DeleteUserAsync(orgId, id, currentUser.Id);
597598

599+
if (result is Success<DeleteUserResponse>)
600+
{
601+
return Ok();
602+
603+
}
604+
598605
return result.MapToActionResultWithSingleErrorMessage();
599606
}
600607

src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/DeleteManagedOrganizationUserAccountCommand.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Bit.Core.Tools.Enums;
1414
using Bit.Core.Tools.Models.Business;
1515
using Bit.Core.Tools.Services;
16+
using Microsoft.Extensions.Logging;
1617

1718

1819
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers;
@@ -27,6 +28,7 @@ public class DeleteManagedOrganizationUserAccountCommand : IDeleteManagedOrganiz
2728
private readonly IOrganizationUserRepository _organizationUserRepository;
2829
private readonly IUserRepository _userRepository;
2930
private readonly ICurrentContext _currentContext;
31+
private readonly ILogger<DeleteManagedOrganizationUserAccountCommand> _logger;
3032
private readonly IReferenceEventService _referenceEventService;
3133
private readonly IPushNotificationService _pushService;
3234

@@ -38,6 +40,7 @@ public DeleteManagedOrganizationUserAccountCommand(
3840
IOrganizationUserRepository organizationUserRepository,
3941
IUserRepository userRepository,
4042
ICurrentContext currentContext,
43+
ILogger<DeleteManagedOrganizationUserAccountCommand> logger,
4144
IReferenceEventService referenceEventService,
4245
IPushNotificationService pushService)
4346
{
@@ -48,6 +51,7 @@ public DeleteManagedOrganizationUserAccountCommand(
4851
_organizationUserRepository = organizationUserRepository;
4952
_userRepository = userRepository;
5053
_currentContext = currentContext;
54+
_logger = logger;
5155
_referenceEventService = referenceEventService;
5256
_pushService = pushService;
5357
}
@@ -184,9 +188,9 @@ private async Task CancelPremiumsAsync(List<Valid<DeleteUserValidationRequest>>
184188
{
185189
await _userService.CancelPremiumAsync(user);
186190
}
187-
catch (GatewayException)
191+
catch (GatewayException exception)
188192
{
189-
193+
_logger.LogWarning(exception, "Failed to cancel the user's premium.");
190194
}
191195
}
192196
}

src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/DeleteManagedOrganizationUserAccountValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private static ValidationResult<DeleteUserValidationRequest> EnsureUserStatusIsN
116116

117117
private static ValidationResult<DeleteUserValidationRequest> PreventSelfDeletion(DeleteUserValidationRequest request)
118118
{
119-
if (request.OrganizationUser?.UserId == request.DeletingUserId)
119+
if (request.OrganizationUser.UserId == request.DeletingUserId)
120120
{
121121
return new Invalid<DeleteUserValidationRequest>(new BadRequestError<DeleteUserValidationRequest>("You cannot delete yourself.", request));
122122
}
@@ -126,7 +126,7 @@ private static ValidationResult<DeleteUserValidationRequest> PreventSelfDeletion
126126

127127
private async Task<ValidationResult<DeleteUserValidationRequest>> EnsureOnlyOwnersCanDeleteOwnersAsync(DeleteUserValidationRequest request)
128128
{
129-
if (request.OrganizationUser?.Type != OrganizationUserType.Owner)
129+
if (request.OrganizationUser.Type != OrganizationUserType.Owner)
130130
{
131131
return new Valid<DeleteUserValidationRequest>(request);
132132
}

0 commit comments

Comments
 (0)