From c940dec7c8b7ae0086ea137a500db2b3bdd2de60 Mon Sep 17 00:00:00 2001 From: Eduardo Lopes <155753879+eduardolopesx03@users.noreply.github.com> Date: Mon, 9 Feb 2026 20:34:08 -0300 Subject: [PATCH 1/3] Update development database connection --- appsettings.Development.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appsettings.Development.json b/appsettings.Development.json index 1dedf75..0bc8a6a 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "Default": "Host=localhost;Port=5432;Database=linegestao;Username=linegestao_app;Password=CHANGE_ME" + "Default": "Host=localhost;Port=5432;Database=linegestao;Username=linegestao_app;Password=255851Ed@" }, "Jwt": { "Key": "dev-only-please-replace-with-env-variable-in-production", From 6e0e332f792257ae5968e5c5c5c98770085975fd Mon Sep 17 00:00:00 2001 From: Eduardo Lopes <155753879+eduardolopesx03@users.noreply.github.com> Date: Mon, 9 Feb 2026 20:43:49 -0300 Subject: [PATCH 2/3] Ensure admin user credentials are synced --- Data/SeedData.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Data/SeedData.cs b/Data/SeedData.cs index cf97836..66adf30 100644 --- a/Data/SeedData.cs +++ b/Data/SeedData.cs @@ -78,6 +78,28 @@ public static class SeedData await userManager.AddToRoleAsync(adminUser, "admin"); } } + else + { + existingAdmin.UserName = options.AdminEmail; + existingAdmin.Email = options.AdminEmail; + existingAdmin.Name = options.AdminName; + existingAdmin.TenantId = tenant.Id; + existingAdmin.EmailConfirmed = true; + existingAdmin.IsActive = true; + + await userManager.UpdateAsync(existingAdmin); + + if (!await userManager.CheckPasswordAsync(existingAdmin, options.AdminPassword)) + { + var resetToken = await userManager.GeneratePasswordResetTokenAsync(existingAdmin); + await userManager.ResetPasswordAsync(existingAdmin, resetToken, options.AdminPassword); + } + + if (!await userManager.IsInRoleAsync(existingAdmin, "admin")) + { + await userManager.AddToRoleAsync(existingAdmin, "admin"); + } + } tenantProvider.SetTenantId(null); } 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 3/3] 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()) };