Update PhoneNumberTokenProvider.cs
Add license header. Hyphenate two-factor authentication in documentation. Add line breaks before return statements. Use string interpolation instead of string concatenation.
This commit is contained in:
parent
c58ab9247c
commit
be334b0d00
|
|
@ -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;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
@ -12,7 +15,7 @@ namespace Microsoft.AspNetCore.Identity
|
||||||
where TUser : class
|
where TUser : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a flag indicating whether the token provider can generate a token suitable for two factor authentication token for
|
/// Returns a flag indicating whether the token provider can generate a token suitable for two-factor authentication token for
|
||||||
/// the specified <paramref name="user"/>.
|
/// the specified <paramref name="user"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="manager">The <see cref="UserManager{TUser}"/> that can be used to retrieve user properties.</param>
|
/// <param name="manager">The <see cref="UserManager{TUser}"/> that can be used to retrieve user properties.</param>
|
||||||
|
|
@ -20,7 +23,7 @@ namespace Microsoft.AspNetCore.Identity
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// The <see cref="Task"/> that represents the asynchronous operation, containing the a flag indicating if a two
|
/// The <see cref="Task"/> that represents the asynchronous operation, containing the a flag indicating if a two
|
||||||
/// factor token could be generated by this provider for the specified <paramref name="user"/>.
|
/// factor token could be generated by this provider for the specified <paramref name="user"/>.
|
||||||
/// The task will return true if a two factor authentication token could be generated as the user has
|
/// The task will return true if a two-factor authentication token could be generated as the user has
|
||||||
/// a telephone number, otherwise false.
|
/// a telephone number, otherwise false.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public override async Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<TUser> manager, TUser user)
|
public override async Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<TUser> manager, TUser user)
|
||||||
|
|
@ -29,7 +32,9 @@ namespace Microsoft.AspNetCore.Identity
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(manager));
|
throw new ArgumentNullException(nameof(manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
var phoneNumber = await manager.GetPhoneNumberAsync(user);
|
var phoneNumber = await manager.GetPhoneNumberAsync(user);
|
||||||
|
|
||||||
return !string.IsNullOrWhiteSpace(phoneNumber) && await manager.IsPhoneNumberConfirmedAsync(user);
|
return !string.IsNullOrWhiteSpace(phoneNumber) && await manager.IsPhoneNumberConfirmedAsync(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,8 +54,10 @@ namespace Microsoft.AspNetCore.Identity
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(manager));
|
throw new ArgumentNullException(nameof(manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
var phoneNumber = await manager.GetPhoneNumberAsync(user);
|
var phoneNumber = await manager.GetPhoneNumberAsync(user);
|
||||||
return "PhoneNumber:" + purpose + ":" + phoneNumber;
|
|
||||||
|
return $"{PhoneNumber}:{purpose}:{phoneNumber}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue