mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 16:42:50 -05:00
delete organization
This commit is contained in:
@ -0,0 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class OrganizationDeleteRequestModel
|
||||
{
|
||||
[Required]
|
||||
public string MasterPasswordHash { get; set; }
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ namespace Bit.Core.Services
|
||||
Task UpgradePlanAsync(Guid organizationId, PlanType plan, int additionalSeats);
|
||||
Task AdjustSeatsAsync(Guid organizationId, int seatAdjustment);
|
||||
Task<Tuple<Organization, OrganizationUser>> SignUpAsync(OrganizationSignup organizationSignup);
|
||||
Task DeleteAsync(Organization organization);
|
||||
Task UpdateAsync(Organization organization, bool updateBilling = false);
|
||||
Task<OrganizationUser> InviteUserAsync(Guid organizationId, Guid invitingUserId, string email,
|
||||
Enums.OrganizationUserType type, IEnumerable<SubvaultUser> subvaults);
|
||||
|
@ -570,6 +570,21 @@ namespace Bit.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(Organization organization)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(organization.StripeSubscriptionId))
|
||||
{
|
||||
var subscriptionService = new StripeSubscriptionService();
|
||||
var canceledSub = await subscriptionService.CancelAsync(organization.StripeSubscriptionId, false);
|
||||
if(!canceledSub.CanceledAt.HasValue)
|
||||
{
|
||||
throw new BadRequestException("Unable to cancel subscription.");
|
||||
}
|
||||
}
|
||||
|
||||
await _organizationRepository.DeleteAsync(organization);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(Organization organization, bool updateBilling = false)
|
||||
{
|
||||
if(organization.Id == default(Guid))
|
||||
|
Reference in New Issue
Block a user