From 366d1a699f9bf35780fec8502c6fe3bf96fcb36d Mon Sep 17 00:00:00 2001 From: Todd Martin Date: Sat, 14 Jun 2025 12:40:43 -0400 Subject: [PATCH] Change email OTP to 6 digits --- .../Identity/TokenProviders/EmailTokenProvider.cs | 2 +- .../TokenProviders/EmailTwoFactorTokenProvider.cs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Core/Auth/Identity/TokenProviders/EmailTokenProvider.cs b/src/Core/Auth/Identity/TokenProviders/EmailTokenProvider.cs index be94124c03..9906c29d16 100644 --- a/src/Core/Auth/Identity/TokenProviders/EmailTokenProvider.cs +++ b/src/Core/Auth/Identity/TokenProviders/EmailTokenProvider.cs @@ -25,7 +25,7 @@ public class EmailTokenProvider : IUserTwoFactorTokenProvider }; } - public int TokenLength { get; protected set; } = 8; + public int TokenLength { get; protected set; } = 6; public bool TokenAlpha { get; protected set; } = false; public bool TokenNumeric { get; protected set; } = true; diff --git a/src/Core/Auth/Identity/TokenProviders/EmailTwoFactorTokenProvider.cs b/src/Core/Auth/Identity/TokenProviders/EmailTwoFactorTokenProvider.cs index 2f8481cea2..3101974b94 100644 --- a/src/Core/Auth/Identity/TokenProviders/EmailTwoFactorTokenProvider.cs +++ b/src/Core/Auth/Identity/TokenProviders/EmailTwoFactorTokenProvider.cs @@ -7,17 +7,18 @@ using Microsoft.Extensions.DependencyInjection; namespace Bit.Core.Auth.Identity.TokenProviders; +/// +/// 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. +/// public class EmailTwoFactorTokenProvider : EmailTokenProvider { public EmailTwoFactorTokenProvider( [FromKeyedServices("persistent")] IDistributedCache distributedCache) : base(distributedCache) - { - TokenAlpha = false; - TokenNumeric = true; - TokenLength = 6; - } + { } public override Task CanGenerateTwoFactorTokenAsync(UserManager manager, User user) {