// 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.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Identity
{
///
/// Provides an abstraction for a storing information which can be used to implement account lockout,
/// including access failures and lockout status
///
/// The type that represents a user.
public interface IUserLockoutStore : IUserStore where TUser : class
{
///
/// Gets the last a user's last lockout expired, if any.
/// Any time in the past should be indicates a user is not locked out.
///
/// The user whose lockout date should be retrieved.
/// The used to propagate notifications that the operation should be canceled.
///
/// A that represents the result of the asynchronous query, a containing the last time
/// a user's lockout expired, if any.
///
Task GetLockoutEndDateAsync(TUser user, CancellationToken cancellationToken);
///
/// Locks out a user until the specified end date has passed. Setting a end date in the past immediately unlocks a user.
///
/// The user whose lockout date should be set.
/// The after which the 's lockout should end.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation.
Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken);
///
/// Records that a failed access has occurred, incrementing the failed access count.
///
/// The user whose cancellation count should be incremented.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the incremented failed access count.
Task IncrementAccessFailedCountAsync(TUser user, CancellationToken cancellationToken);
///
/// Resets a user's failed access count.
///
/// The user whose failed access count should be reset.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation.
/// This is typically called after the account is successfully accessed.
Task ResetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken);
///
/// Retrieves the current failed access count for the specified .
///
/// The user whose failed access count should be retrieved.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the failed access count.
Task GetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken);
///
/// Retrieves a flag indicating whether user lockout can enabled for the specified user.
///
/// The user whose ability to be locked out should be returned.
/// The used to propagate notifications that the operation should be canceled.
///
/// The that represents the asynchronous operation, true if a user can be locked out, otherwise false.
///
Task GetLockoutEnabledAsync(TUser user, CancellationToken cancellationToken);
///
/// Set the flag indicating if the specified can be locked out.
///
/// The user whose ability to be locked out should be set.
/// A flag indicating if lock out can be enabled for the specified .
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation.
Task SetLockoutEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken);
}
}