mirror of
https://github.com/bitwarden/server.git
synced 2025-06-06 19:20:33 -05:00
Refactor AcceptOrgUserCommand and ConfirmOrganizationUserCommand to streamline two-factor authentication checks by removing redundant conditions and simplifying logic flow.
This commit is contained in:
parent
398a542528
commit
8fc79f26d1
@ -246,9 +246,10 @@ public class AcceptOrgUserCommand : IAcceptOrgUserCommand
|
|||||||
{
|
{
|
||||||
throw new BadRequestException("You cannot join this organization until you enable two-step login on your user account.");
|
throw new BadRequestException("You cannot join this organization until you enable two-step login on your user account.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!await _twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(user))
|
if (!await _twoFactorIsEnabledQuery.TwoFactorIsEnabledAsync(user))
|
||||||
{
|
{
|
||||||
var invitedTwoFactorPolicies = await _policyService.GetPoliciesApplicableToUserAsync(user.Id,
|
var invitedTwoFactorPolicies = await _policyService.GetPoliciesApplicableToUserAsync(user.Id,
|
||||||
@ -260,4 +261,3 @@ public class AcceptOrgUserCommand : IAcceptOrgUserCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -186,9 +186,10 @@ public class ConfirmOrganizationUserCommand : IConfirmOrganizationUserCommand
|
|||||||
{
|
{
|
||||||
throw new BadRequestException("User does not have two-step login enabled.");
|
throw new BadRequestException("User does not have two-step login enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
var orgRequiresTwoFactor = (await _policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.TwoFactorAuthentication))
|
var orgRequiresTwoFactor = (await _policyService.GetPoliciesApplicableToUserAsync(user.Id, PolicyType.TwoFactorAuthentication))
|
||||||
.Any(p => p.OrganizationId == organizationId);
|
.Any(p => p.OrganizationId == organizationId);
|
||||||
if (orgRequiresTwoFactor && !userTwoFactorEnabled)
|
if (orgRequiresTwoFactor && !userTwoFactorEnabled)
|
||||||
@ -196,7 +197,6 @@ public class ConfirmOrganizationUserCommand : IConfirmOrganizationUserCommand
|
|||||||
throw new BadRequestException("User does not have two-step login enabled.");
|
throw new BadRequestException("User does not have two-step login enabled.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DeleteAndPushUserRegistrationAsync(Guid organizationId, Guid userId)
|
private async Task DeleteAndPushUserRegistrationAsync(Guid organizationId, Guid userId)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user