Added seed from config instead of code
This commit is contained in:
@ -15,19 +15,9 @@ namespace Birdmap.DAL.Entities.Configurations
|
||||
.HasConversion(u => u.ToString(), u => new Uri(u))
|
||||
.IsRequired();
|
||||
|
||||
builder.HasData(
|
||||
new Service
|
||||
{
|
||||
Id = 1,
|
||||
Name = "KMLabz services",
|
||||
Uri = new Uri("https://birb.k8s.kmlabz.com/devices")
|
||||
},
|
||||
new Service
|
||||
{
|
||||
Id = 2,
|
||||
Name = "Local Database",
|
||||
Uri = new Uri("/health", UriKind.Relative)
|
||||
});
|
||||
builder.Property(s => s.IsFromConfig)
|
||||
.HasDefaultValue(false)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using static Birdmap.Common.PasswordHelper;
|
||||
|
||||
namespace Birdmap.DAL.Entities.Configurations
|
||||
{
|
||||
@ -23,25 +22,9 @@ 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,
|
||||
});
|
||||
builder.Property(u => u.IsFromConfig)
|
||||
.HasDefaultValue(false)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user