diff --git a/src/Identity/Extensions.Core/src/EmailTokenProvider.cs b/src/Identity/Extensions.Core/src/EmailTokenProvider.cs
index a6ee043876..69daaf73be 100644
--- a/src/Identity/Extensions.Core/src/EmailTokenProvider.cs
+++ b/src/Identity/Extensions.Core/src/EmailTokenProvider.cs
@@ -1,3 +1,6 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Identity
@@ -10,29 +13,31 @@ namespace Microsoft.AspNetCore.Identity
where TUser : class
{
///
- /// Checks if a two factor authentication token can be generated for the specified .
+ /// Checks if a two-factor authentication token can be generated for the specified .
///
/// The to retrieve the from.
- /// The to check for the possibility of generating a two factor authentication token.
+ /// The to check for the possibility of generating a two-factor authentication token.
/// True if the user has an email address set, otherwise false.
public override async Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user)
{
var email = await manager.GetEmailAsync(user);
+
return !string.IsNullOrWhiteSpace(email) && await manager.IsEmailConfirmedAsync(user);
}
///
/// Returns the a value for the user used as entropy in the generated token.
///
- /// The purpose of the two factor authentication token.
+ /// The purpose of the two-factor authentication token.
/// The to retrieve the from.
- /// The to check for the possibility of generating a two factor authentication token.
+ /// The to check for the possibility of generating a two-factor authentication token.
/// A string suitable for use as entropy in token generation.
public override async Task GetUserModifierAsync(string purpose, UserManager manager,
TUser user)
{
var email = await manager.GetEmailAsync(user);
- return "Email:" + purpose + ":" + email;
+
+ return $"{Email}:{purpose}:{email}";
}
}
-}
\ No newline at end of file
+}