mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 13:08:17 -05:00
Add feature flag to CreateAdminInitiatedSponsorshipHandler
This commit is contained in:
parent
bbb109cba8
commit
f6ec513443
@ -157,6 +157,7 @@ public static class FeatureFlagKeys
|
|||||||
public const string PrivateKeyRegeneration = "pm-12241-private-key-regeneration";
|
public const string PrivateKeyRegeneration = "pm-12241-private-key-regeneration";
|
||||||
public const string AppReviewPrompt = "app-review-prompt";
|
public const string AppReviewPrompt = "app-review-prompt";
|
||||||
public const string ResellerManagedOrgAlert = "PM-15814-alert-owners-of-reseller-managed-orgs";
|
public const string ResellerManagedOrgAlert = "PM-15814-alert-owners-of-reseller-managed-orgs";
|
||||||
|
public const string PM17772_AdminInitiatedSponsorships = "pm-17772-admin-initiated-sponsorships";
|
||||||
public const string Argon2Default = "argon2-default";
|
public const string Argon2Default = "argon2-default";
|
||||||
public const string UsePricingService = "use-pricing-service";
|
public const string UsePricingService = "use-pricing-service";
|
||||||
public const string RecordInstallationLastActivityDate = "installation-last-activity-date";
|
public const string RecordInstallationLastActivityDate = "installation-last-activity-date";
|
||||||
|
@ -16,13 +16,14 @@ public class CreateSponsorshipCommand : ICreateSponsorshipCommand
|
|||||||
private readonly BaseCreateSponsorshipHandler _createSponsorshipHandler;
|
private readonly BaseCreateSponsorshipHandler _createSponsorshipHandler;
|
||||||
|
|
||||||
public CreateSponsorshipCommand(
|
public CreateSponsorshipCommand(
|
||||||
|
IFeatureService featureService,
|
||||||
IOrganizationSponsorshipRepository organizationSponsorshipRepository,
|
IOrganizationSponsorshipRepository organizationSponsorshipRepository,
|
||||||
IUserService userService,
|
IUserService userService,
|
||||||
ICurrentContext currentContext)
|
ICurrentContext currentContext)
|
||||||
{
|
{
|
||||||
_organizationSponsorshipRepository = organizationSponsorshipRepository;
|
_organizationSponsorshipRepository = organizationSponsorshipRepository;
|
||||||
|
|
||||||
var adminInitiatedSponsorshipHandler = new CreateAdminInitiatedSponsorshipHandler(currentContext);
|
var adminInitiatedSponsorshipHandler = new CreateAdminInitiatedSponsorshipHandler(currentContext, featureService);
|
||||||
_createSponsorshipHandler = new CreateSponsorshipHandler(userService, organizationSponsorshipRepository);
|
_createSponsorshipHandler = new CreateSponsorshipHandler(userService, organizationSponsorshipRepository);
|
||||||
_createSponsorshipHandler.SetNext(adminInitiatedSponsorshipHandler);
|
_createSponsorshipHandler.SetNext(adminInitiatedSponsorshipHandler);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using Bit.Core.Entities;
|
using Bit.Core.Entities;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Exceptions;
|
using Bit.Core.Exceptions;
|
||||||
|
using Bit.Core.Services;
|
||||||
|
|
||||||
namespace Bit.Core.OrganizationFeatures.OrganizationSponsorships.FamiliesForEnterprise.SponsorshipCreation;
|
namespace Bit.Core.OrganizationFeatures.OrganizationSponsorships.FamiliesForEnterprise.SponsorshipCreation;
|
||||||
|
|
||||||
@ -10,13 +11,19 @@ namespace Bit.Core.OrganizationFeatures.OrganizationSponsorships.FamiliesForEnte
|
|||||||
/// sponsorship initiated by organization members with specific permissions to manage members/users.
|
/// sponsorship initiated by organization members with specific permissions to manage members/users.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CreateAdminInitiatedSponsorshipHandler(
|
public class CreateAdminInitiatedSponsorshipHandler(
|
||||||
ICurrentContext currentContext) : BaseCreateSponsorshipHandler
|
ICurrentContext currentContext,
|
||||||
|
IFeatureService featureService) : BaseCreateSponsorshipHandler
|
||||||
{
|
{
|
||||||
public override async Task<OrganizationSponsorship> HandleAsync(CreateSponsorshipRequest request)
|
public override async Task<OrganizationSponsorship> HandleAsync(CreateSponsorshipRequest request)
|
||||||
{
|
{
|
||||||
var isAdminInitiated = false;
|
var isAdminInitiated = false;
|
||||||
if (currentContext.UserId != request.SponsoringMember.UserId)
|
if (currentContext.UserId != request.SponsoringMember.UserId)
|
||||||
{
|
{
|
||||||
|
if (!featureService.IsEnabled(FeatureFlagKeys.PM17772_AdminInitiatedSponsorships))
|
||||||
|
{
|
||||||
|
throw new BadRequestException("Feature 'pm-17772-admin-initiated-sponsorships' is not enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
var organization = currentContext.Organizations.First(x => x.Id == request.SponsoringOrganization.Id);
|
var organization = currentContext.Organizations.First(x => x.Id == request.SponsoringOrganization.Id);
|
||||||
OrganizationUserType[] allowedUserTypes =
|
OrganizationUserType[] allowedUserTypes =
|
||||||
[
|
[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user