1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-21 09:31:34 -05:00

feat(otp): Revert [PM-18612] Consolidate all email OTP to use 6 digits

This reverts commit 737f549f82.
This commit is contained in:
Todd Martin
2025-07-08 13:59:44 -04:00
committed by GitHub
parent 3d09db8e31
commit b4c9133d12
2 changed files with 6 additions and 10 deletions

View File

@ -7,9 +7,6 @@ using Microsoft.Extensions.DependencyInjection;
namespace Bit.Core.Auth.Identity.TokenProviders;
/// <summary>
/// Generates and validates tokens for email OTPs.
/// </summary>
public class EmailTokenProvider : IUserTwoFactorTokenProvider<User>
{
private const string CacheKeyFormat = "EmailToken_{0}_{1}_{2}";
@ -28,7 +25,7 @@ public class EmailTokenProvider : IUserTwoFactorTokenProvider<User>
};
}
public int TokenLength { get; protected set; } = 6;
public int TokenLength { get; protected set; } = 8;
public bool TokenAlpha { get; protected set; } = false;
public bool TokenNumeric { get; protected set; } = true;

View File

@ -10,18 +10,17 @@ using Microsoft.Extensions.DependencyInjection;
namespace Bit.Core.Auth.Identity.TokenProviders;
/// <summary>
/// Generates tokens for email two-factor authentication.
/// It inherits from the EmailTokenProvider class, which manages the persistence and validation of tokens,
/// and adds additional validation to ensure that 2FA is enabled for the user.
/// </summary>
public class EmailTwoFactorTokenProvider : EmailTokenProvider
{
public EmailTwoFactorTokenProvider(
[FromKeyedServices("persistent")]
IDistributedCache distributedCache) :
base(distributedCache)
{ }
{
TokenAlpha = false;
TokenNumeric = true;
TokenLength = 6;
}
public override Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<User> manager, User user)
{