From e88dc6a347a2c9d6dc78e369445a82d5743f6e46 Mon Sep 17 00:00:00 2001 From: Oleg Zhuk Date: Fri, 1 Nov 2024 15:17:14 +0200 Subject: [PATCH] VCST-2048: Use ClaimsPrincipalExtensions GetUserId (#124) feat: Replace custom code with ClaimsPrincipalExtensions that resolves user id and name from IdentityOptions settings. --- .../VirtoCommerce.QuoteModule.Core.csproj | 2 +- .../VirtoCommerce.QuoteModule.Data.MySql.csproj | 4 ++-- .../VirtoCommerce.QuoteModule.Data.PostgreSql.csproj | 4 ++-- .../VirtoCommerce.QuoteModule.Data.SqlServer.csproj | 4 ++-- .../VirtoCommerce.QuoteModule.Data.csproj | 4 ++-- .../Authorization/QuoteAuthorizationHandler.cs | 5 +---- src/VirtoCommerce.QuoteModule.Web/module.manifest | 2 +- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/VirtoCommerce.QuoteModule.Core/VirtoCommerce.QuoteModule.Core.csproj b/src/VirtoCommerce.QuoteModule.Core/VirtoCommerce.QuoteModule.Core.csproj index 0e327da..403829b 100644 --- a/src/VirtoCommerce.QuoteModule.Core/VirtoCommerce.QuoteModule.Core.csproj +++ b/src/VirtoCommerce.QuoteModule.Core/VirtoCommerce.QuoteModule.Core.csproj @@ -16,7 +16,7 @@ - + \ No newline at end of file diff --git a/src/VirtoCommerce.QuoteModule.Data.MySql/VirtoCommerce.QuoteModule.Data.MySql.csproj b/src/VirtoCommerce.QuoteModule.Data.MySql/VirtoCommerce.QuoteModule.Data.MySql.csproj index 4f8585b..331665f 100644 --- a/src/VirtoCommerce.QuoteModule.Data.MySql/VirtoCommerce.QuoteModule.Data.MySql.csproj +++ b/src/VirtoCommerce.QuoteModule.Data.MySql/VirtoCommerce.QuoteModule.Data.MySql.csproj @@ -5,11 +5,11 @@ enable - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.QuoteModule.Data.PostgreSql/VirtoCommerce.QuoteModule.Data.PostgreSql.csproj b/src/VirtoCommerce.QuoteModule.Data.PostgreSql/VirtoCommerce.QuoteModule.Data.PostgreSql.csproj index ba2dbaa..388fa99 100644 --- a/src/VirtoCommerce.QuoteModule.Data.PostgreSql/VirtoCommerce.QuoteModule.Data.PostgreSql.csproj +++ b/src/VirtoCommerce.QuoteModule.Data.PostgreSql/VirtoCommerce.QuoteModule.Data.PostgreSql.csproj @@ -6,11 +6,11 @@ NU1903 - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.QuoteModule.Data.SqlServer/VirtoCommerce.QuoteModule.Data.SqlServer.csproj b/src/VirtoCommerce.QuoteModule.Data.SqlServer/VirtoCommerce.QuoteModule.Data.SqlServer.csproj index e2ac6aa..0a7b18b 100644 --- a/src/VirtoCommerce.QuoteModule.Data.SqlServer/VirtoCommerce.QuoteModule.Data.SqlServer.csproj +++ b/src/VirtoCommerce.QuoteModule.Data.SqlServer/VirtoCommerce.QuoteModule.Data.SqlServer.csproj @@ -5,11 +5,11 @@ enable - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.QuoteModule.Data/VirtoCommerce.QuoteModule.Data.csproj b/src/VirtoCommerce.QuoteModule.Data/VirtoCommerce.QuoteModule.Data.csproj index 8026a04..2887aad 100644 --- a/src/VirtoCommerce.QuoteModule.Data/VirtoCommerce.QuoteModule.Data.csproj +++ b/src/VirtoCommerce.QuoteModule.Data/VirtoCommerce.QuoteModule.Data.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/src/VirtoCommerce.QuoteModule.ExperienceApi/Authorization/QuoteAuthorizationHandler.cs b/src/VirtoCommerce.QuoteModule.ExperienceApi/Authorization/QuoteAuthorizationHandler.cs index d89c73f..b50e507 100644 --- a/src/VirtoCommerce.QuoteModule.ExperienceApi/Authorization/QuoteAuthorizationHandler.cs +++ b/src/VirtoCommerce.QuoteModule.ExperienceApi/Authorization/QuoteAuthorizationHandler.cs @@ -122,9 +122,6 @@ private async Task GetContact(string userId) private static string GetUserId(AuthorizationHandlerContext context) { - return - context.User.FindFirstValue(ClaimTypes.NameIdentifier) ?? - context.User.FindFirstValue("name") ?? - AnonymousUser.UserName; + return context.User.GetUserId() ?? AnonymousUser.UserName; } } diff --git a/src/VirtoCommerce.QuoteModule.Web/module.manifest b/src/VirtoCommerce.QuoteModule.Web/module.manifest index 88214a5..6ca068e 100644 --- a/src/VirtoCommerce.QuoteModule.Web/module.manifest +++ b/src/VirtoCommerce.QuoteModule.Web/module.manifest @@ -4,7 +4,7 @@ 3.818.0 - 3.841.0 + 3.861.0