Added NLog, Added UserService, Added database and seed seed
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using static Birdmap.Common.PasswordHelper;
|
||||
|
||||
namespace Birdmap.DAL.Entities.Configurations
|
||||
{
|
||||
@ -7,6 +8,9 @@ namespace Birdmap.DAL.Entities.Configurations
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<User> builder)
|
||||
{
|
||||
builder.HasIndex(u => u.Name)
|
||||
.IsUnique();
|
||||
|
||||
builder.Property(u => u.Name)
|
||||
.IsRequired();
|
||||
|
||||
@ -18,6 +22,26 @@ namespace Birdmap.DAL.Entities.Configurations
|
||||
|
||||
builder.Property(u => u.Role)
|
||||
.IsRequired();
|
||||
|
||||
CreatePasswordHash("pass", out var hash, out var salt);
|
||||
|
||||
builder.HasData(
|
||||
new User
|
||||
{
|
||||
Id = 1,
|
||||
Name = "admin",
|
||||
PasswordHash = hash,
|
||||
PasswordSalt = salt,
|
||||
Role = Roles.Admin,
|
||||
},
|
||||
new User
|
||||
{
|
||||
Id = 2,
|
||||
Name = "user",
|
||||
PasswordHash = hash,
|
||||
PasswordSalt = salt,
|
||||
Role = Roles.User,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user