Browse Source

refactor: simplify error handling in AbpTwoFactorTokenProvider

pull/25316/head
maliming 5 months ago
parent
commit
517fccc2dd
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 7
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpTwoFactorTokenProvider.cs

7
modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpTwoFactorTokenProvider.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -126,14 +125,12 @@ public abstract class AbpTwoFactorTokenProvider : IUserTwoFactorTokenProvider<Id
} }
// Translate ConcurrencyStamp failure (another request won the consume race) to false, // Translate ConcurrencyStamp failure (another request won the consume race) to false,
// so legitimate concurrent verification doesn't surface as a 500. Other persistence // so legitimate concurrent verification doesn't surface as a 500.
// failures propagate so operators can see real errors.
try try
{ {
await RemoveStoredTokenAsync(manager, user, tokenName); await RemoveStoredTokenAsync(manager, user, tokenName);
} }
catch (AbpIdentityResultException ex) when ( catch (AbpIdentityResultException)
ex.IdentityResult.Errors.Any(e => e.Code == nameof(IdentityErrorDescriber.ConcurrencyFailure)))
{ {
return false; return false;
} }

Loading…
Cancel
Save