Browse Source

Removing unneccesary method call (#363)

main
Eric Fleming 6 years ago
committed by GitHub
parent
commit
599db2ee26
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      src/Web/Startup.cs

22
src/Web/Startup.cs

@ -85,7 +85,10 @@ namespace Microsoft.eShopWeb.Web
{
ConfigureCookieSettings(services);
CreateIdentityIfNotCreated(services);
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddDefaultUI()
.AddEntityFrameworkStores<AppIdentityDbContext>()
.AddDefaultTokenProviders();
services.AddMediatR(typeof(BasketViewModelService).Assembly);
@ -140,23 +143,6 @@ namespace Microsoft.eShopWeb.Web
_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)
{
services.Configure<CookiePolicyOptions>(options =>

Loading…
Cancel
Save