This commit is contained in:
Eduardo Lopes 2026-02-09 21:44:03 -03:00 committed by GitHub
commit 1e80d49ad2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 3 deletions

View File

@ -145,11 +145,14 @@ public class AuthController : ControllerBase
var roles = await _userManager.GetRolesAsync(user); var roles = await _userManager.GetRolesAsync(user);
var displayName = user.Name ?? user.Email ?? string.Empty;
var userEmail = user.Email ?? string.Empty;
var claims = new List<Claim> var claims = new List<Claim>
{ {
new(JwtRegisteredClaimNames.Sub, user.Id.ToString()), new(JwtRegisteredClaimNames.Sub, user.Id.ToString()),
new(JwtRegisteredClaimNames.Email, user.Email ?? string.Empty), new(JwtRegisteredClaimNames.Email, userEmail),
new("name", user.Name), new("name", displayName),
new("tenantId", tenantId.ToString()) new("tenantId", tenantId.ToString())
}; };

View File

@ -78,6 +78,28 @@ public static class SeedData
await userManager.AddToRoleAsync(adminUser, "admin"); 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); tenantProvider.SetTenantId(null);
} }

View File

@ -1,6 +1,6 @@
{ {
"ConnectionStrings": { "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": { "Jwt": {
"Key": "dev-only-please-replace-with-env-variable-in-production", "Key": "dev-only-please-replace-with-env-variable-in-production",