committed by
GitHub
5 changed files with 88 additions and 52 deletions
@ -0,0 +1,31 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System; |
|||
|
|||
namespace Microsoft.eShopWeb.Web.Configuration |
|||
{ |
|||
public static class ConfigureCookieSettings |
|||
{ |
|||
public static void Configure(IServiceCollection services) |
|||
{ |
|||
services.Configure<CookiePolicyOptions>(options => |
|||
{ |
|||
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
|
|||
options.CheckConsentNeeded = context => true; |
|||
options.MinimumSameSitePolicy = SameSiteMode.None; |
|||
}); |
|||
services.ConfigureApplicationCookie(options => |
|||
{ |
|||
options.Cookie.HttpOnly = true; |
|||
options.ExpireTimeSpan = TimeSpan.FromHours(1); |
|||
options.LoginPath = "/Account/Login"; |
|||
options.LogoutPath = "/Account/Logout"; |
|||
options.Cookie = new CookieBuilder |
|||
{ |
|||
IsEssential = true // required for auth to work without explicit user consent; adjust to suit your privacy policy
|
|||
}; |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using Microsoft.eShopWeb.ApplicationCore.Interfaces; |
|||
using Microsoft.eShopWeb.ApplicationCore.Services; |
|||
using Microsoft.eShopWeb.Infrastructure.Data; |
|||
using Microsoft.eShopWeb.Infrastructure.Logging; |
|||
using Microsoft.eShopWeb.Infrastructure.Services; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace Microsoft.eShopWeb.Web.Configuration |
|||
{ |
|||
public static class ConfigureCoreServices |
|||
{ |
|||
public static void Configure(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
services.AddScoped(typeof(IAsyncRepository<>), typeof(EfRepository<>)); |
|||
services.AddScoped<IBasketService, BasketService>(); |
|||
services.AddScoped<IOrderService, OrderService>(); |
|||
services.AddScoped<IOrderRepository, OrderRepository>(); |
|||
services.AddSingleton<IUriComposer>(new UriComposer(configuration.Get<CatalogSettings>())); |
|||
services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>)); |
|||
services.AddTransient<IEmailSender, EmailSender>(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using MediatR; |
|||
using Microsoft.eShopWeb.Web.Interfaces; |
|||
using Microsoft.eShopWeb.Web.Services; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace Microsoft.eShopWeb.Web.Configuration |
|||
{ |
|||
public static class ConfigureWebServices |
|||
{ |
|||
public static void Configure(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
services.AddMediatR(typeof(BasketViewModelService).Assembly); |
|||
services.AddScoped<IBasketViewModelService, BasketViewModelService>(); |
|||
services.AddScoped<CatalogViewModelService>(); |
|||
services.AddScoped<ICatalogItemViewModelService, CatalogItemViewModelService>(); |
|||
services.Configure<CatalogSettings>(configuration); |
|||
services.AddScoped<ICatalogViewModelService, CachedCatalogViewModelService>(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue