1
0
mirror of https://github.com/bitwarden/server synced 2025-12-23 03:33:35 +00:00

added licensing apis, refactored some services

This commit is contained in:
Kyle Spearrin
2017-08-30 11:23:55 -04:00
parent ccd6b784be
commit 8b947cafaf
11 changed files with 134 additions and 9 deletions

View File

@@ -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)