1
0
mirror of https://github.com/bitwarden/server synced 2025-12-29 22:54:00 +00:00

Moved policy service auto confirm check to accept and confirm

This commit is contained in:
Jared McCannon
2025-12-04 10:28:52 -06:00
parent 4d78f79c22
commit 937d4f850e
4 changed files with 275 additions and 132 deletions

View File

@@ -11,4 +11,4 @@ public record UserDoesNotHaveTwoFactorEnabled() : BadRequestError("User does not
public record OrganizationEnforcesSingleOrgPolicy() : BadRequestError("Cannot confirm this member to the organization until they leave or remove all other organizations");
public record OtherOrganizationEnforcesSingleOrgPolicy() : BadRequestError("Cannot confirm this member to the organization because they are in another organization which forbids it.");
public record AutomaticallyConfirmUsersPolicyIsNotEnabled() : BadRequestError("Cannot confirm this member because the Automatically Confirm Users policy is not enabled.");
public record ProviderUsersCannotJoin() : BadRequestError("Organization has enabled Automatic User Confirmation policy and it does not support provider users.");
public record ProviderUsersCannotJoin() : BadRequestError("An organization the user is a part of has enabled Automatic User Confirmation policy and it does not support provider users joining.");

View File

@@ -19,6 +19,10 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements
/// <param name="policyDetails">Collection of policy details that apply to this user id</param>
public class AutomaticUserConfirmationPolicyRequirement(IEnumerable<PolicyDetails> policyDetails) : IPolicyRequirement
{
public bool CanBeGrantedEmergencyAccess() => policyDetails.Any();
public bool UserBelongsToOrganizationWithAutomaticUserConfirmationEnabled() => policyDetails.Any();
public bool IsEnabled(Guid organizationId) => policyDetails.Any(p => p.OrganizationId == organizationId);
public bool IsEnabledAndUserIsAProvider(Guid organizationId) =>