Eric Fleming
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
4 additions and
18 deletions
-
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 => |
|
|
|
|