// 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.Collections.Generic;
using System.Threading;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Identity
{
///
/// Provides the APIs for managing user in a persistence store.
///
/// The type encapsulating a user.
public class AspNetUserManager : UserManager, IDisposable where TUser : class
{
private readonly CancellationToken _cancel;
///
/// Constructs a new instance of .
///
/// The persistence store the manager will operate over.
/// The accessor used to access the .
/// The password hashing implementation to use when saving passwords.
/// A collection of to validate users against.
/// A collection of to validate passwords against.
/// The to use when generating index keys for users.
/// The used to provider error messages.
/// The used to resolve services.
/// The logger used to log messages, warnings and errors.
public AspNetUserManager(IUserStore store,
IOptions optionsAccessor,
IPasswordHasher passwordHasher,
IEnumerable> userValidators,
IEnumerable> passwordValidators,
ILookupNormalizer keyNormalizer,
IdentityErrorDescriber errors,
IServiceProvider services,
ILogger> logger)
: base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
{
_cancel = services?.GetService()?.HttpContext?.RequestAborted ?? CancellationToken.None;
}
///
/// The cancellation token assocated with the current HttpContext.RequestAborted or CancellationToken.None if unavailable.
///
protected override CancellationToken CancellationToken => _cancel;
}
}