From 323cd176b7b5fb58e2b73c2e093f2e31c4a2eb02 Mon Sep 17 00:00:00 2001 From: cuqmbr Date: Wed, 27 Jul 2022 20:08:38 +0300 Subject: [PATCH] feat: add Username claim to jwt --- Server/Program.cs | 1 - Server/Services/AuthenticationService.cs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/Program.cs b/Server/Program.cs index 180bbae..c64a7d7 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -14,7 +14,6 @@ var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers().AddNewtonsoftJson(o => { - o.SerializerSettings.ContractResolver = new DefaultContractResolver(); o.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); builder.Services.AddEndpointsApiExplorer(); diff --git a/Server/Services/AuthenticationService.cs b/Server/Services/AuthenticationService.cs index fd8e849..c1c9109 100644 --- a/Server/Services/AuthenticationService.cs +++ b/Server/Services/AuthenticationService.cs @@ -63,7 +63,8 @@ public class AuthenticationService { var subject = new ClaimsIdentity(new[] { new Claim("Id", user.Id.ToString()), - new Claim(ClaimTypes.Role, user.Role), + new Claim("Username", user.Username), + new Claim(ClaimTypes.Role, user.Role) }); return subject;