// 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.AspNet.Identity
{
///
/// Provides an abstraction for token generators.
///
/// The type encapsulating a user.
public interface IUserTokenProvider where TUser : class
{
///
/// Gets the name of the token provider.
///
/// The name of the token provider.
string Name { get; }
///
/// Generates a token for the specified and , as an asynchronous operation.
///
/// The purpose the token will be used for.
/// The that can be used to retrieve user properties.
/// The user a token should be generated for.
///
/// The that represents the asynchronous operation, containing the token for the specified
/// and .
///
///
/// The parameter allows a token generator to be used for multiple types of token whilst
/// insuring a token for one purpose cannot be used for another. For example if you specified a purpose of "Email"
/// and validated it with the same purpose a token with the purpose of TOTP would not pass the heck even if it was
/// for the same user.
///
/// Implementations of should validate that purpose is not null or empty to
/// help with token separation.
///
Task GenerateAsync(string purpose, UserManager manager, TUser user);
///
/// Returns a flag indicating whether the specified is valid for the given
/// and , as an asynchronous operation.
///
/// The purpose the token will be used for.
/// The token to validate.
/// The that can be used to retrieve user properties.
/// The user a token should be validated for.
///
/// The that represents the asynchronous operation, containing the a flag indicating the result
/// of validating the for the specified and .
/// The task will return true if the token is valid, otherwise false.
///
Task ValidateAsync(string purpose, string token, UserManager manager, TUser user);
///
/// Returns a flag indicating whether the token provider can generate a token suitable for two factor authentication token for
/// the specified .
///
/// The that can be used to retrieve user properties.
/// The user a token could be generated for.
///
/// The that represents the asynchronous operation, containing the a flag indicating if a two
/// factor token could be generated by this provider for the specified and .
/// The task will return true if a two factor authentication token could be generated, otherwise false.
///
Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user);
}
}