Skip to content

Commit 689e530

Browse files
pwuexeccaptainsafia
authored andcommitted
Simplifying TFA Validation Logic in MapIdentityApi (#57989)
1 parent e5ec677 commit 689e530

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Identity/Core/src/IdentityApiEndpointRouteBuilderExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,14 @@ await signInManager.ValidateSecurityStampAsync(refreshTicket.Principal) is not T
274274
return CreateValidationProblem("CannotResetSharedKeyAndEnable",
275275
"Resetting the 2fa shared key must disable 2fa until a 2fa token based on the new shared key is validated.");
276276
}
277-
else if (string.IsNullOrEmpty(tfaRequest.TwoFactorCode))
277+
278+
if (string.IsNullOrEmpty(tfaRequest.TwoFactorCode))
278279
{
279280
return CreateValidationProblem("RequiresTwoFactor",
280281
"No 2fa token was provided by the request. A valid 2fa token is required to enable 2fa.");
281282
}
282-
else if (!await userManager.VerifyTwoFactorTokenAsync(user, userManager.Options.Tokens.AuthenticatorTokenProvider, tfaRequest.TwoFactorCode))
283+
284+
if (!await userManager.VerifyTwoFactorTokenAsync(user, userManager.Options.Tokens.AuthenticatorTokenProvider, tfaRequest.TwoFactorCode))
283285
{
284286
return CreateValidationProblem("InvalidTwoFactorCode",
285287
"The 2fa token provided by the request was invalid. A valid 2fa token is required to enable 2fa.");

0 commit comments

Comments
 (0)