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