Skip to content

Commit 530d946

Browse files
[PM-29061] Remove Feature Flag 24996 (#6744)
* refactor(billing): Remove flag uses * refactor(billing): remove redundant endpoint * chore(billing): remove the flag * fix(billing): revert changes * Revert "fix(billing): revert changes" This reverts commit 92271b3. * test(billing): update tests
1 parent 5e735c8 commit 530d946

5 files changed

Lines changed: 0 additions & 65 deletions

File tree

src/Api/Billing/Controllers/AccountsController.cs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
using Bit.Api.Models.Response;
44
using Bit.Api.Utilities;
55
using Bit.Core;
6-
using Bit.Core.Auth.UserFeatures.TwoFactorAuth.Interfaces;
76
using Bit.Core.Billing.Models;
87
using Bit.Core.Billing.Models.Business;
98
using Bit.Core.Billing.Services;
109
using Bit.Core.Exceptions;
11-
using Bit.Core.KeyManagement.Queries.Interfaces;
12-
using Bit.Core.Models.Business;
1310
using Bit.Core.Services;
1411
using Bit.Core.Settings;
1512
using Bit.Core.Utilities;
@@ -22,59 +19,9 @@ namespace Bit.Api.Billing.Controllers;
2219
[Authorize("Application")]
2320
public class AccountsController(
2421
IUserService userService,
25-
ITwoFactorIsEnabledQuery twoFactorIsEnabledQuery,
26-
IUserAccountKeysQuery userAccountKeysQuery,
2722
IFeatureService featureService,
2823
ILicensingService licensingService) : Controller
2924
{
30-
// TODO: Remove when pm-24996-implement-upgrade-from-free-dialog is removed
31-
[HttpPost("premium")]
32-
public async Task<PaymentResponseModel> PostPremiumAsync(
33-
PremiumRequestModel model,
34-
[FromServices] GlobalSettings globalSettings)
35-
{
36-
var user = await userService.GetUserByPrincipalAsync(User);
37-
if (user == null)
38-
{
39-
throw new UnauthorizedAccessException();
40-
}
41-
42-
var valid = model.Validate(globalSettings);
43-
UserLicense? license = null;
44-
if (valid && globalSettings.SelfHosted)
45-
{
46-
license = await ApiHelpers.ReadJsonFileFromBody<UserLicense>(HttpContext, model.License);
47-
}
48-
49-
if (!valid && !globalSettings.SelfHosted && string.IsNullOrWhiteSpace(model.Country))
50-
{
51-
throw new BadRequestException("Country is required.");
52-
}
53-
54-
if (!valid || (globalSettings.SelfHosted && license == null))
55-
{
56-
throw new BadRequestException("Invalid license.");
57-
}
58-
59-
var result = await userService.SignUpPremiumAsync(user, model.PaymentToken,
60-
model.PaymentMethodType!.Value, model.AdditionalStorageGb.GetValueOrDefault(0), license,
61-
new TaxInfo { BillingAddressCountry = model.Country, BillingAddressPostalCode = model.PostalCode });
62-
63-
var userTwoFactorEnabled = await twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(user);
64-
var userHasPremiumFromOrganization = await userService.HasPremiumFromOrganization(user);
65-
var organizationIdsClaimingActiveUser = await GetOrganizationIdsClaimingUserAsync(user.Id);
66-
var accountKeys = await userAccountKeysQuery.Run(user);
67-
68-
var profile = new ProfileResponseModel(user, accountKeys, null, null, null, userTwoFactorEnabled,
69-
userHasPremiumFromOrganization, organizationIdsClaimingActiveUser);
70-
return new PaymentResponseModel
71-
{
72-
UserProfile = profile,
73-
PaymentIntentClientSecret = result.Item2,
74-
Success = result.Item1
75-
};
76-
}
77-
7825
// TODO: Migrate to Query / AccountBillingVNextController as part of Premium -> Organization upgrade work.
7926
[HttpGet("subscription")]
8027
public async Task<SubscriptionResponseModel> GetSubscriptionAsync(

src/Api/Billing/Controllers/VNext/AccountBillingVNextController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public async Task<IResult> UpdatePaymentMethodAsync(
7070
}
7171

7272
[HttpPost("subscription")]
73-
[RequireFeature(FeatureFlagKeys.PM24996ImplementUpgradeFromFreeDialog)]
7473
[InjectUser]
7574
public async Task<IResult> CreateSubscriptionAsync(
7675
[BindNever] User user,

src/Api/Billing/Controllers/VNext/SelfHostedAccountBillingVNextController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Bit.Api.Billing.Attributes;
22
using Bit.Api.Billing.Models.Requests.Premium;
33
using Bit.Api.Utilities;
4-
using Bit.Core;
54
using Bit.Core.Billing.Models.Business;
65
using Bit.Core.Billing.Premium.Commands;
76
using Bit.Core.Entities;
@@ -20,7 +19,6 @@ public class SelfHostedAccountBillingVNextController(
2019
ICreatePremiumSelfHostedSubscriptionCommand createPremiumSelfHostedSubscriptionCommand) : BaseBillingController
2120
{
2221
[HttpPost("license")]
23-
[RequireFeature(FeatureFlagKeys.PM24996ImplementUpgradeFromFreeDialog)]
2422
[InjectUser]
2523
public async Task<IResult> UploadLicenseAsync(
2624
[BindNever] User user,

src/Core/Constants.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ public static class FeatureFlagKeys
178178
/* Billing Team */
179179
public const string TrialPayment = "PM-8163-trial-payment";
180180
public const string PM25379_UseNewOrganizationMetadataStructure = "pm-25379-use-new-organization-metadata-structure";
181-
public const string PM24996ImplementUpgradeFromFreeDialog = "pm-24996-implement-upgrade-from-free-dialog";
182181
public const string PM24032_NewNavigationPremiumUpgradeButton = "pm-24032-new-navigation-premium-upgrade-button";
183182
public const string PM23713_PremiumBadgeOpensNewPremiumUpgradeDialog = "pm-23713-premium-badge-opens-new-premium-upgrade-dialog";
184183
public const string PM26793_FetchPremiumPriceFromPricingService = "pm-26793-fetch-premium-price-from-pricing-service";

test/Api.Test/Billing/Controllers/AccountsControllerTests.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
using System.Security.Claims;
22
using Bit.Api.Billing.Controllers;
33
using Bit.Core;
4-
using Bit.Core.Auth.UserFeatures.TwoFactorAuth.Interfaces;
54
using Bit.Core.Billing.Constants;
65
using Bit.Core.Billing.Models.Business;
76
using Bit.Core.Billing.Services;
87
using Bit.Core.Entities;
98
using Bit.Core.Enums;
10-
using Bit.Core.KeyManagement.Queries.Interfaces;
119
using Bit.Core.Models.Business;
1210
using Bit.Core.Services;
1311
using Bit.Core.Settings;
@@ -29,8 +27,6 @@ public class AccountsControllerTests : IDisposable
2927
private readonly IUserService _userService;
3028
private readonly IFeatureService _featureService;
3129
private readonly IStripePaymentService _paymentService;
32-
private readonly ITwoFactorIsEnabledQuery _twoFactorIsEnabledQuery;
33-
private readonly IUserAccountKeysQuery _userAccountKeysQuery;
3430
private readonly ILicensingService _licensingService;
3531
private readonly GlobalSettings _globalSettings;
3632
private readonly AccountsController _sut;
@@ -40,15 +36,11 @@ public AccountsControllerTests()
4036
_userService = Substitute.For<IUserService>();
4137
_featureService = Substitute.For<IFeatureService>();
4238
_paymentService = Substitute.For<IStripePaymentService>();
43-
_twoFactorIsEnabledQuery = Substitute.For<ITwoFactorIsEnabledQuery>();
44-
_userAccountKeysQuery = Substitute.For<IUserAccountKeysQuery>();
4539
_licensingService = Substitute.For<ILicensingService>();
4640
_globalSettings = new GlobalSettings { SelfHosted = false };
4741

4842
_sut = new AccountsController(
4943
_userService,
50-
_twoFactorIsEnabledQuery,
51-
_userAccountKeysQuery,
5244
_featureService,
5345
_licensingService
5446
);

0 commit comments

Comments
 (0)