Removing unneccesary method call (#363)

This commit is contained in:
Eric Fleming
2020-04-09 14:10:08 -06:00
committed by GitHub
parent 1007a6b0fc
commit 599db2ee26

View File

@@ -85,7 +85,10 @@ namespace Microsoft.eShopWeb.Web
{ {
ConfigureCookieSettings(services); ConfigureCookieSettings(services);
CreateIdentityIfNotCreated(services); services.AddIdentity<ApplicationUser, IdentityRole>()
.AddDefaultUI()
.AddEntityFrameworkStores<AppIdentityDbContext>()
.AddDefaultTokenProviders();
services.AddMediatR(typeof(BasketViewModelService).Assembly); services.AddMediatR(typeof(BasketViewModelService).Assembly);
@@ -140,23 +143,6 @@ namespace Microsoft.eShopWeb.Web
_services = services; // used to debug registered services _services = services; // used to debug registered services
} }
private static void CreateIdentityIfNotCreated(IServiceCollection services)
{
var sp = services.BuildServiceProvider();
using (var scope = sp.CreateScope())
{
var existingUserManager = scope.ServiceProvider
.GetService<UserManager<ApplicationUser>>();
if(existingUserManager == null)
{
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddDefaultUI()
.AddEntityFrameworkStores<AppIdentityDbContext>()
.AddDefaultTokenProviders();
}
}
}
private static void ConfigureCookieSettings(IServiceCollection services) private static void ConfigureCookieSettings(IServiceCollection services)
{ {
services.Configure<CookiePolicyOptions>(options => services.Configure<CookiePolicyOptions>(options =>