Use AddHttpContextAccessor method added in aspnet/HttpAbstractions#947
This commit is contained in:
parent
700c2afc21
commit
8136fc5306
|
|
@ -100,7 +100,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
services.AddTransient<SessionManager, SessionManager<TUser, TApplication>>();
|
||||
services.AddTransient<SessionManager<TUser, TApplication>>();
|
||||
services.AddTransient<IRedirectUriResolver, ClientApplicationValidator<TApplication>>();
|
||||
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpContextAccessor();
|
||||
|
||||
services.Configure(configure);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
/// <param name="context"></param>
|
||||
protected override void SetupIdentityServices(IServiceCollection services, object context)
|
||||
{
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddIdentity<TUser, TRole>(options =>
|
||||
{
|
||||
options.Password.RequireDigit = false;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
/// <param name="context"></param>
|
||||
protected virtual IdentityBuilder SetupBuilder(IServiceCollection services, object context)
|
||||
{
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddDataProtection();
|
||||
var builder = services.AddIdentityCore<TUser>(options =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
});
|
||||
|
||||
// Hosting doesn't add IHttpContextAccessor by default
|
||||
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpContextAccessor();
|
||||
// Identity services
|
||||
services.TryAddScoped<IUserValidator<TUser>, UserValidator<TUser>>();
|
||||
services.TryAddScoped<IPasswordValidator<TUser>, PasswordValidator<TUser>>();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.InMemory.Test
|
|||
public InMemoryEFUserStoreTestWithGenerics()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddDbContext<InMemoryContextWithGenerics>(options => options.UseInMemoryDatabase("Scratch"));
|
||||
_context = services.BuildServiceProvider().GetRequiredService<InMemoryContextWithGenerics>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.InMemory.Test
|
|||
public static IServiceCollection CreateTestServices()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddLogging();
|
||||
services.AddIdentity<IdentityUser, IdentityRole>();
|
||||
return services;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
|
|||
{
|
||||
services = new ServiceCollection();
|
||||
}
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddDbContext<TContext>(options => options.UseSqlServer(connectionString));
|
||||
return services;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
|
|||
|
||||
protected override void SetupIdentityServices(IServiceCollection services, object context)
|
||||
{
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddSingleton((TestDbContext)context);
|
||||
services.AddLogging();
|
||||
services.AddSingleton<ILogger<UserManager<TUser>>>(new TestLogger<UserManager<TUser>>());
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
|
|||
{
|
||||
services = new ServiceCollection();
|
||||
}
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddDbContext<TContext>(options => options.UseSqlServer(connectionString));
|
||||
return services;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
{
|
||||
var services = new ServiceCollection()
|
||||
.AddSingleton<IConfiguration>(new ConfigurationBuilder().Build())
|
||||
.AddSingleton<IHttpContextAccessor, HttpContextAccessor>()
|
||||
.AddHttpContextAccessor()
|
||||
.AddLogging();
|
||||
services.AddIdentity<TestUser, TestRole>()
|
||||
.AddUserStore<NoopUserStore>()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
.AddSingleton<IConfiguration>(config)
|
||||
.AddTransient<IUserStore<TestUser>, NoopUserStore>();
|
||||
services.AddIdentity<TestUser, TestRole>();
|
||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddLogging();
|
||||
var manager = services.BuildServiceProvider().GetRequiredService<UserManager<TestUser>>();
|
||||
Assert.NotNull(manager.PasswordHasher);
|
||||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
var services = new ServiceCollection()
|
||||
.AddSingleton<IConfiguration>(config)
|
||||
.AddTransient<IUserStore<TestUser>, NoopUserStore>()
|
||||
.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
.AddHttpContextAccessor();
|
||||
|
||||
services.AddLogging();
|
||||
|
||||
|
|
@ -1544,7 +1544,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
|||
.AddLogging()
|
||||
.AddSingleton<IdentityErrorDescriber>(describer)
|
||||
.AddSingleton<IUserStore<TestUser>>(store.Object)
|
||||
.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||
.AddHttpContextAccessor();
|
||||
|
||||
services.AddIdentity<TestUser, TestRole>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue