Skip to content

Commit

Permalink
Merge branch 'release/6.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
vc-ci committed Nov 11, 2022
2 parents 52bdf23 + 6802c3d commit 4efa74a
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

<PropertyGroup>
<Product>VirtoCommerce</Product>
<Copyright>Copyright © VirtoCommerce 2011-2020</Copyright>
<Copyright>Copyright © VirtoCommerce 2011-2022</Copyright>
<Authors>VirtoCommerce</Authors>
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>6.6.0</VersionPrefix>
<VersionPrefix>6.7.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' != '' AND '$(BuildNumber)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
Expand Down
13 changes: 13 additions & 0 deletions VirtoCommerce.Storefront.Model/Security/ConfirmEmailModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;

namespace VirtoCommerce.Storefront.Model.Security
{
public class ConfirmEmailModel
{
[Required(ErrorMessage = "A UserId is required")]
public string UserId { get; set; }

[Required(ErrorMessage = "A Token is required")]
public string Token { get; set; }
}
}
4 changes: 2 additions & 2 deletions VirtoCommerce.Storefront.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VirtoCommerce.Storefront", "VirtoCommerce.Storefront\VirtoCommerce.Storefront.csproj", "{84C14E0A-0F36-4BB5-9C00-7E8FB72891C2}"
EndProject
Expand Down
31 changes: 31 additions & 0 deletions VirtoCommerce.Storefront/Controllers/Api/ApiAccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,37 @@ public async Task<ActionResult<UserActionIdentityResult>> ResetPassword([FromBod
return result;
}

// POST: storefrontapi/account/confirmemail
[HttpPost("confirmemail")]
[AllowAnonymous]
public async Task<ActionResult<UserActionIdentityResult>> ConfirmEmail([FromBody] ConfirmEmailModel model)
{
TryValidateModel(model);

if (!ModelState.IsValid)
{
return UserActionIdentityResult.Failed(ModelState.Values.SelectMany(x => x.Errors)
.Select(x => new IdentityError { Description = x.ErrorMessage })
.ToArray());
}

var user = await _signInManager.UserManager.FindByIdAsync(model.UserId);

if (user == null)
{
// Don't reveal that the user does not exist
return UserActionIdentityResult.Failed(SecurityErrorDescriber.InvalidToken());
}

var confirmEmailResult = await _signInManager.UserManager.ConfirmEmailAsync(user, model.Token);

if (!confirmEmailResult.Succeeded)
{
return UserActionIdentityResult.Failed(confirmEmailResult.Errors.ToArray());
}

return UserActionIdentityResult.Success;
}

private static string GetUserEmail(User user)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using VirtoCommerce.Storefront.Model;
using VirtoCommerce.Storefront.Model.Common;
using VirtoCommerce.Storefront.Model.StaticContent;
using VirtoCommerce.Storefront.Models;

namespace VirtoCommerce.Storefront.Controllers.Api
{
Expand All @@ -20,19 +21,44 @@ public ApiStaticContentController(IWorkContextAccessor workContextAccessor, ISto
{
}

// POST: storefrontapi/content/reset-cache
[HttpPost("reset-cache")]
public ActionResult ResetCache([FromBody] ResetCacheEventModel webHookEvent)
{
if (TryResetCacheInternal(webHookEvent?.EventBody?.FirstOrDefault()?.Type))
{
return Ok("OK");
}
// we can't return 400, because webhook module use it to repeat request
return Ok("Failed");
}

// POST: storefrontapi/content/reset-cache/theme
[HttpPost("reset-cache/{region}")]
public ActionResult ResetCache([FromRoute] string region)
{
if (TryResetCacheInternal(region))
{
return Ok("OK");
}
// we can't return 400, because webhook module use it to repeat request
return Ok("Failed");
}

private static bool TryResetCacheInternal(string region)
{
switch (region)
{
case "theme": ThemeEngineCacheRegion.ExpireRegion();
break;
case "theme":
case "themes":
ThemeEngineCacheRegion.ExpireRegion();
return true;
case "pages":
case "blogs":
StaticContentCacheRegion.ExpireRegion();
break;
return true;
}
return Ok();
return false;
}

// POST: storefrontapi/content/pages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected void AddCurrentUser(HttpRequestMessage request)
/// <param name="request"></param>
protected void AddUserIp(HttpRequestMessage request)
{
var userIp = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
var userIp = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress.ToString();

if (!string.IsNullOrEmpty(userIp))
{
Expand Down
29 changes: 29 additions & 0 deletions VirtoCommerce.Storefront/Models/ResetCacheModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VirtoCommerce.Storefront.Models
{
/// <summary>
/// Cache Event Model For Web Hook from Virto Commmerce Platform
/// </summary>
public class ResetCacheEventModel
{
public string EventId { get; set; }

public ResetCacheEventBodyModel[] EventBody { get; set; }
}

public class ResetCacheEventBodyModel
{
public string ObjectType { get; set; }

public string Id { get; set; }

public string Path { get; set; }

public string Type { get; set; }
}
}
10 changes: 9 additions & 1 deletion VirtoCommerce.Storefront/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using System.IO.Compression;
using FluentValidation.AspNetCore;
using GraphQL.Client.Abstractions;
using GraphQL.Client.Http;
Expand All @@ -21,6 +22,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.WebEncoders;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
Expand Down Expand Up @@ -326,7 +328,13 @@ public void ConfigureServices(IServiceCollection services)
c.CustomSchemaIds(type => (Attribute.GetCustomAttribute(type, typeof(SwaggerSchemaIdAttribute)) as SwaggerSchemaIdAttribute)?.Id ?? type.FriendlyId());
});

services.AddResponseCompression();
services.Configure<BrotliCompressionProviderOptions>(options => {
options.Level = CompressionLevel.Optimal;
});
services.AddResponseCompression(options => {
options.EnableForHttps = true;
options.Providers.Add<BrotliCompressionProvider>();
});

services.AddProxy(builder => builder.AddHttpMessageHandler(sp => sp.GetService<AuthenticationHandlerFactory>().CreateAuthHandler()));

Expand Down
10 changes: 5 additions & 5 deletions VirtoCommerce.Storefront/VirtoCommerce.Storefront.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<UserSecretsId>0cd403c4-2cd0-42b3-987a-02900f4a683e</UserSecretsId>
<Description>The storefront implementation of the Virto Commerce platform.</Description>
<PackageLicenseUrl>https://virtocommerce.com/open-source-license</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/VirtoCommerce/vc-storefront-core</PackageProjectUrl>
<RepositoryUrl>https://github.com/VirtoCommerce/vc-storefront-core</RepositoryUrl>
<PackageProjectUrl>https://github.com/VirtoCommerce/vc-storefront</PackageProjectUrl>
<RepositoryUrl>https://github.com/VirtoCommerce/vc-storefront</RepositoryUrl>

<PackageIconUrl>https://virtocommerce.com/themes/assets/logo.jpg</PackageIconUrl>
<PackageReleaseNotes></PackageReleaseNotes>
Expand Down Expand Up @@ -47,10 +47,10 @@
<PackageReference Include="FluentValidation.AspNetCore" Version="10.4.0" />

<PackageReference Include="Markdig" Version="0.30.2" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights.SnapshotCollector" Version="1.4.3" />
<PackageReference Include="Microsoft.ApplicationInsights.Web" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.Web" Version="2.21.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="6.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="6.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.4" />
Expand Down

0 comments on commit 4efa74a

Please sign in to comment.