Merge 337c48b0f0 into b924397f52
This commit is contained in:
commit
1e80d49ad2
|
|
@ -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())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue