This commit is contained in:
john 2025-05-18 22:22:20 +02:00
parent fbc6f562e3
commit d7e0c59559
31 changed files with 249 additions and 57 deletions

View file

@ -9,16 +9,23 @@ internal class UserIdentityTypeConfiguration : IEntityTypeConfiguration<UserIden
public void Configure(EntityTypeBuilder<UserIdentity> builder)
{
builder.ToTable("user_identity");
builder.OwnsOne(u => u.Password, pw =>
{
pw.Property(p => p.Hash)
.HasColumnName("password_hash")
.IsRequired(false);
builder.OwnsOne(
u => u.Password,
pw =>
{
pw.Property(p => p.Hash).HasColumnName("password_hash").IsRequired(false);
pw.Property(p => p.Salt).HasColumnName("password_salt").IsRequired(false);
}
);
pw.Property(p => p.Salt)
.HasColumnName("password_salt")
.IsRequired(false);
});
builder.OwnsMany(u => u.Sessions).WithOwner().HasForeignKey("user_id");
builder
.OwnsMany(u => u.Roles, entity =>
{
entity.WithOwner().HasForeignKey(x => x.UserId);
entity.HasKey(x => new { x.UserId, x.Role});
});
}
}