From 3d6350f05056017377a32f51002515cbad769ac0 Mon Sep 17 00:00:00 2001 From: Nishchal Date: Sat, 5 Jun 2021 22:48:50 +0700 Subject: [PATCH] fix(userId): fix user not found error --- Micro.Auth.Api/GraphQL/Types/RefreshTokenType.cs | 1 - Micro.Auth.Api/Internal/UserData/Extensions/UserIdExtension.cs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Micro.Auth.Api/GraphQL/Types/RefreshTokenType.cs b/Micro.Auth.Api/GraphQL/Types/RefreshTokenType.cs index b131e84..68dc2aa 100644 --- a/Micro.Auth.Api/GraphQL/Types/RefreshTokenType.cs +++ b/Micro.Auth.Api/GraphQL/Types/RefreshTokenType.cs @@ -1,4 +1,3 @@ -using GraphQL.Types; using Micro.Auth.Api.GraphQL.Federation; using Micro.Auth.Storage; diff --git a/Micro.Auth.Api/Internal/UserData/Extensions/UserIdExtension.cs b/Micro.Auth.Api/Internal/UserData/Extensions/UserIdExtension.cs index 0c8977b..697b2a3 100644 --- a/Micro.Auth.Api/Internal/UserData/Extensions/UserIdExtension.cs +++ b/Micro.Auth.Api/Internal/UserData/Extensions/UserIdExtension.cs @@ -1,6 +1,7 @@ using System.Security.Claims; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.IdentityModel.JsonWebTokens; namespace Micro.Auth.Api.Internal.UserData.Extensions { @@ -13,7 +14,7 @@ public static class UserIdExtension public static string? GetUserId(this IHttpContextAccessor httpContextAccessor) { - return httpContextAccessor.HttpContext?.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; + return httpContextAccessor.HttpContext?.User.FindFirst(JwtRegisteredClaimNames.Sub)?.Value; } } }