mirror of
https://github.com/bitwarden/server.git
synced 2025-07-13 05:38:25 -05:00
added licensing apis, refactored some services
This commit is contained in:
@ -36,6 +36,7 @@ namespace Bit.Core.Services
|
||||
Task DeleteUserAsync(Guid organizationId, Guid organizationUserId, Guid deletingUserId);
|
||||
Task DeleteUserAsync(Guid organizationId, Guid userId);
|
||||
Task<OrganizationLicense> GenerateLicenseAsync(Guid organizationId, Guid installationId);
|
||||
Task<OrganizationLicense> GenerateLicenseAsync(Organization organization, Guid installationId);
|
||||
Task ImportAsync(Guid organizationId, Guid importingUserId, IEnumerable<ImportedGroup> groups,
|
||||
IEnumerable<ImportedOrganizationUser> newUsers, IEnumerable<string> removeUserExternalIds);
|
||||
}
|
||||
|
@ -49,5 +49,6 @@ namespace Bit.Core.Services
|
||||
Task DisablePremiumAsync(Guid userId, DateTime? expirationDate);
|
||||
Task DisablePremiumAsync(User user, DateTime? expirationDate);
|
||||
Task UpdatePremiumExpirationAsync(Guid userId, DateTime? expirationDate);
|
||||
Task<UserLicense> GenerateLicenseAsync(User user, BillingInfo billingInfo = null);
|
||||
}
|
||||
}
|
||||
|
@ -1039,6 +1039,11 @@ namespace Bit.Core.Services
|
||||
public async Task<OrganizationLicense> GenerateLicenseAsync(Guid organizationId, Guid installationId)
|
||||
{
|
||||
var organization = await _organizationRepository.GetByIdAsync(organizationId);
|
||||
return await GenerateLicenseAsync(organization, installationId);
|
||||
}
|
||||
|
||||
public async Task<OrganizationLicense> GenerateLicenseAsync(Organization organization, Guid installationId)
|
||||
{
|
||||
if(organization == null)
|
||||
{
|
||||
throw new NotFoundException();
|
||||
|
@ -721,6 +721,23 @@ namespace Bit.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<UserLicense> GenerateLicenseAsync(User user, BillingInfo billingInfo = null)
|
||||
{
|
||||
if(user == null)
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
if(billingInfo == null && user.Gateway != null)
|
||||
{
|
||||
var paymentService = user.GetPaymentService(_globalSettings);
|
||||
billingInfo = await paymentService.GetBillingAsync(user);
|
||||
}
|
||||
|
||||
return billingInfo == null ? new UserLicense(user, _licenseService) :
|
||||
new UserLicense(user, billingInfo, _licenseService);
|
||||
}
|
||||
|
||||
private async Task<IdentityResult> UpdatePasswordHash(User user, string newPassword, bool validatePassword = true)
|
||||
{
|
||||
if(validatePassword)
|
||||
|
Reference in New Issue
Block a user