From 337c48b0f0759be1c0fb8c4490c01f9b931156c1 Mon Sep 17 00:00:00 2001 From: Eduardo Lopes <155753879+eduardolopesx03@users.noreply.github.com> Date: Mon, 9 Feb 2026 20:47:12 -0300 Subject: [PATCH] Guard null user fields in auth claims --- Controllers/AuthController.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Controllers/AuthController.cs b/Controllers/AuthController.cs index b4a8008..34ffe6b 100644 --- a/Controllers/AuthController.cs +++ b/Controllers/AuthController.cs @@ -145,11 +145,14 @@ public class AuthController : ControllerBase var roles = await _userManager.GetRolesAsync(user); + var displayName = user.Name ?? user.Email ?? string.Empty; + var userEmail = user.Email ?? string.Empty; + var claims = new List { new(JwtRegisteredClaimNames.Sub, user.Id.ToString()), - new(JwtRegisteredClaimNames.Email, user.Email ?? string.Empty), - new("name", user.Name), + new(JwtRegisteredClaimNames.Email, userEmail), + new("name", displayName), new("tenantId", tenantId.ToString()) };