pulizia vecchie metodologie aggiunta user/ruoli
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public class RoleConfiguration : IEntityTypeConfiguration<IdentityRole>
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public void Configure(EntityTypeBuilder<IdentityRole> builder)
|
||||
{
|
||||
builder.HasData(
|
||||
new IdentityRole { Name = "Undef", NormalizedName = "UNDEF" },
|
||||
//new IdentityRole { Name = "ExtUser", NormalizedName = "EXTUSER" },
|
||||
//new IdentityRole { Name = "ExtTransp", NormalizedName = "EXTTRANSP" },
|
||||
new IdentityRole { Name = "User", NormalizedName = "USER" },
|
||||
new IdentityRole { Name = "Admin", NormalizedName = "ADMIN" },
|
||||
new IdentityRole { Name = "SuperAdmin", NormalizedName = "SUPERADMIN" }
|
||||
);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public class UserAdminConfiguration : IEntityTypeConfiguration<IdentityUser>
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public void Configure(EntityTypeBuilder<IdentityUser> builder)
|
||||
{
|
||||
// Default seeded users
|
||||
builder.HasData(
|
||||
// SuperAdmins
|
||||
getNewUser("samuele.locatelli@egalware.com", "th1sIsTh3R1vrOfThNgt202401"),
|
||||
getNewUser("emmanuele.sassi@egalware.com", "th1sIsTh3R1vrOfThNgt202402"),
|
||||
getNewUser("luca.mazzoleni@egalware.com", "th1sIsTh3R1vrOfThNgt202403"),
|
||||
// Admin egalware base
|
||||
getNewUser("info@egalware.com", "th1sIsTh3R1vrOfThNgt202404")
|
||||
);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected PasswordHasher<IdentityUser> hasher = new PasswordHasher<IdentityUser>();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected IdentityUser getNewUser(string email, string passwd)
|
||||
{
|
||||
var newRec = new IdentityUser
|
||||
{
|
||||
UserName = email,
|
||||
NormalizedUserName = email.ToUpper(),
|
||||
Email = email,
|
||||
NormalizedEmail = email.ToUpper(),
|
||||
EmailConfirmed = true,
|
||||
PasswordHash = hasher.HashPassword(null!, passwd),
|
||||
};
|
||||
return newRec;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -60,24 +60,11 @@ namespace MagMan.Data.Admin
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
// nuova gestione in blocco come in GWMS e da https://stackoverflow.com/questions/34343599/how-to-seed-users-and-roles-with-code-first-migration-using-identity-asp-net-cor
|
||||
// Gestione in blocco user/permessi di base (salvata con migrazione AddUserAndRoles) come in GWMS + https://stackoverflow.com/questions/34343599/how-to-seed-users-and-roles-with-code-first-migration-using-identity-asp-net-cor
|
||||
|
||||
builder.Seed();
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
|
||||
// gestione come WDC:
|
||||
#if false
|
||||
|
||||
// aggiunta ruoli
|
||||
builder.ApplyConfiguration(new RoleConfiguration());
|
||||
// aggiunta user admin base
|
||||
builder.ApplyConfiguration(new UserAdminConfiguration());
|
||||
// aggiunta ruoli utente
|
||||
builder.ApplyConfiguration(new UserRoleConfiguration());
|
||||
// Todo: aggiungere configurazione claims oltre ai roles...
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagMan.Data.Admin
|
||||
{
|
||||
public class UserRoleConfiguration : IEntityTypeConfiguration<IdentityUserRole<string>>
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public void Configure(EntityTypeBuilder<IdentityUserRole<string>> builder)
|
||||
{
|
||||
// Default seeded users
|
||||
builder.HasData(
|
||||
//SuperAdmin Samuele
|
||||
seedUserRoles("f15d1e26-d995-4c46-86ca-6a67462424f5", "f66a9c0f-9f6b-4d9d-89d0-bde432a94882"),
|
||||
//SuperAdmin Zaccaria
|
||||
seedUserRoles("0e340d8e-13ae-4468-ac08-ad56b5f8beb0", "f66a9c0f-9f6b-4d9d-89d0-bde432a94882"),
|
||||
//Admin Zaccaria 01
|
||||
seedUserRoles("36562ca7-5ede-4e04-8971-1acd9e4fb9e6", "4225aeef-4a9b-4629-bbb2-4f3ea6c93595"),
|
||||
//CompAdmin Zaccaria 02
|
||||
seedUserRoles("d869584f-f439-4889-aade-b7497f1cb557", "fc7d40cd-35d6-45a1-89b6-ac4ffa6368c5")
|
||||
|
||||
);
|
||||
|
||||
#if false
|
||||
builder.HasData(
|
||||
new IdentityRole { Name = "Undef", NormalizedName = "UNDEF" },
|
||||
//new IdentityRole { Name = "ExtUser", NormalizedName = "EXTUSER" },
|
||||
//new IdentityRole { Name = "ExtTransp", NormalizedName = "EXTTRANSP" },
|
||||
new IdentityRole { Name = "User", NormalizedName = "USER" },
|
||||
new IdentityRole { Name = "Admin", NormalizedName = "ADMIN" },
|
||||
new IdentityRole { Name = "SuperAdmin", NormalizedName = "SUPERADMIN" }
|
||||
);
|
||||
#endif
|
||||
}
|
||||
protected IdentityUserRole<string> seedUserRoles(string userID, string roleId)
|
||||
{
|
||||
var newRec = new IdentityUserRole<string>()
|
||||
{
|
||||
UserId = userID,
|
||||
RoleId = roleId
|
||||
};
|
||||
|
||||
|
||||
return newRec;
|
||||
}
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,6 @@ builder.Services.AddHealthChecksUI(s =>
|
||||
{
|
||||
s.AddHealthCheckEndpoint("MagMan_Services", "health");
|
||||
s.SetEvaluationTimeInSeconds(60);
|
||||
//s.SetEvaluationTimeInSeconds(60);
|
||||
s.SetMinimumSecondsBetweenFailureNotifications(120);
|
||||
s.SetApiMaxActiveRequests(5);
|
||||
s.SetHeaderText("MagMan Health Check Status");
|
||||
|
||||
Reference in New Issue
Block a user