mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
update expiration dates
This commit is contained in:
@ -243,6 +243,8 @@ namespace Bit.Core.Services
|
||||
user.Gateway = Enums.GatewayType.Braintree;
|
||||
user.GatewayCustomerId = customerResult.Target.Id;
|
||||
user.GatewaySubscriptionId = subResult.Target.Id;
|
||||
user.Premium = true;
|
||||
user.PremiumExpirationDate = subResult.Target.BillingPeriodEndDate;
|
||||
}
|
||||
|
||||
public async Task ReinstateSubscriptionAsync(ISubscriber subscriber)
|
||||
|
@ -527,18 +527,31 @@ namespace Bit.Core.Services
|
||||
await _organizationRepository.DeleteAsync(organization);
|
||||
}
|
||||
|
||||
public async Task DisableAsync(Guid organizationId)
|
||||
public async Task DisableAsync(Guid organizationId, DateTime? expirationDate)
|
||||
{
|
||||
var org = await _organizationRepository.GetByIdAsync(organizationId);
|
||||
if(org != null && org.Enabled)
|
||||
{
|
||||
org.Enabled = false;
|
||||
org.ExpirationDate = expirationDate;
|
||||
org.RevisionDate = DateTime.UtcNow;
|
||||
await _organizationRepository.ReplaceAsync(org);
|
||||
|
||||
// TODO: send email to owners?
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateExpirationDateAsync(Guid organizationId, DateTime? expirationDate)
|
||||
{
|
||||
var org = await _organizationRepository.GetByIdAsync(organizationId);
|
||||
if(org != null)
|
||||
{
|
||||
org.ExpirationDate = expirationDate;
|
||||
org.RevisionDate = DateTime.UtcNow;
|
||||
await _organizationRepository.ReplaceAsync(org);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task EnableAsync(Guid organizationId)
|
||||
{
|
||||
var org = await _organizationRepository.GetByIdAsync(organizationId);
|
||||
|
@ -63,6 +63,8 @@ namespace Bit.Core.Services
|
||||
user.Gateway = Enums.GatewayType.Stripe;
|
||||
user.GatewayCustomerId = customer.Id;
|
||||
user.GatewaySubscriptionId = subscription.Id;
|
||||
user.Premium = true;
|
||||
user.PremiumExpirationDate = subscription.CurrentPeriodEnd;
|
||||
}
|
||||
|
||||
public async Task AdjustStorageAsync(IStorableSubscriber storableSubscriber, int additionalStorage,
|
||||
|
@ -574,6 +574,7 @@ namespace Bit.Core.Services
|
||||
{
|
||||
user.MaxStorageGb = 10240; // 10 TB
|
||||
user.LicenseKey = license.LicenseKey;
|
||||
user.PremiumExpirationDate = license.Expires;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -640,12 +641,24 @@ namespace Bit.Core.Services
|
||||
await paymentService.ReinstateSubscriptionAsync(user);
|
||||
}
|
||||
|
||||
public async Task DisablePremiumAsync(Guid userId)
|
||||
public async Task DisablePremiumAsync(Guid userId, DateTime? expirationDate)
|
||||
{
|
||||
var user = await _userRepository.GetByIdAsync(userId);
|
||||
if(user != null && user.Premium)
|
||||
{
|
||||
user.Premium = false;
|
||||
user.PremiumExpirationDate = expirationDate;
|
||||
user.RevisionDate = DateTime.UtcNow;
|
||||
await _userRepository.ReplaceAsync(user);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdatePremiumExpirationAsync(Guid userId, DateTime? expirationDate)
|
||||
{
|
||||
var user = await _userRepository.GetByIdAsync(userId);
|
||||
if(user != null)
|
||||
{
|
||||
user.PremiumExpirationDate = expirationDate;
|
||||
user.RevisionDate = DateTime.UtcNow;
|
||||
await _userRepository.ReplaceAsync(user);
|
||||
}
|
||||
|
Reference in New Issue
Block a user