Update EmailTokenProvider.cs
This commit is contained in:
parent
be334b0d00
commit
5972fa0004
|
|
@ -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;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Identity
|
namespace Microsoft.AspNetCore.Identity
|
||||||
|
|
@ -10,29 +13,31 @@ namespace Microsoft.AspNetCore.Identity
|
||||||
where TUser : class
|
where TUser : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if a two factor authentication token can be generated for the specified <paramref name="user"/>.
|
/// Checks if a two-factor authentication token can be generated for the specified <paramref name="user"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="manager">The <see cref="UserManager{TUser}"/> to retrieve the <paramref name="user"/> from.</param>
|
/// <param name="manager">The <see cref="UserManager{TUser}"/> to retrieve the <paramref name="user"/> from.</param>
|
||||||
/// <param name="user">The <typeparamref name="TUser"/> to check for the possibility of generating a two factor authentication token.</param>
|
/// <param name="user">The <typeparamref name="TUser"/> to check for the possibility of generating a two-factor authentication token.</param>
|
||||||
/// <returns>True if the user has an email address set, otherwise false.</returns>
|
/// <returns>True if the user has an email address set, otherwise false.</returns>
|
||||||
public override async Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<TUser> manager, TUser user)
|
public override async Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<TUser> manager, TUser user)
|
||||||
{
|
{
|
||||||
var email = await manager.GetEmailAsync(user);
|
var email = await manager.GetEmailAsync(user);
|
||||||
|
|
||||||
return !string.IsNullOrWhiteSpace(email) && await manager.IsEmailConfirmedAsync(user);
|
return !string.IsNullOrWhiteSpace(email) && await manager.IsEmailConfirmedAsync(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the a value for the user used as entropy in the generated token.
|
/// Returns the a value for the user used as entropy in the generated token.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="purpose">The purpose of the two factor authentication token.</param>
|
/// <param name="purpose">The purpose of the two-factor authentication token.</param>
|
||||||
/// <param name="manager">The <see cref="UserManager{TUser}"/> to retrieve the <paramref name="user"/> from.</param>
|
/// <param name="manager">The <see cref="UserManager{TUser}"/> to retrieve the <paramref name="user"/> from.</param>
|
||||||
/// <param name="user">The <typeparamref name="TUser"/> to check for the possibility of generating a two factor authentication token.</param>
|
/// <param name="user">The <typeparamref name="TUser"/> to check for the possibility of generating a two-factor authentication token.</param>
|
||||||
/// <returns>A string suitable for use as entropy in token generation.</returns>
|
/// <returns>A string suitable for use as entropy in token generation.</returns>
|
||||||
public override async Task<string> GetUserModifierAsync(string purpose, UserManager<TUser> manager,
|
public override async Task<string> GetUserModifierAsync(string purpose, UserManager<TUser> manager,
|
||||||
TUser user)
|
TUser user)
|
||||||
{
|
{
|
||||||
var email = await manager.GetEmailAsync(user);
|
var email = await manager.GetEmailAsync(user);
|
||||||
return "Email:" + purpose + ":" + email;
|
|
||||||
|
return $"{Email}:{purpose}:{email}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue