| | | 1 | | using ArturRios.Heimdall.Domain.Entities; |
| | | 2 | | using Microsoft.EntityFrameworkCore; |
| | | 3 | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | 4 | | |
| | | 5 | | namespace ArturRios.Heimdall.Data.EntityMaps; |
| | | 6 | | |
| | | 7 | | internal static class PasswordResetTokenDbMap |
| | | 8 | | { |
| | | 9 | | public static void Configure(this EntityTypeBuilder<PasswordResetToken> token) |
| | | 10 | | { |
| | 3 | 11 | | token.ToTable("password_reset_token"); |
| | | 12 | | |
| | | 13 | | // Internal bigint Id only; no PublicId — the caller-facing reference is the Token string (§4.0). |
| | 3 | 14 | | token.HasKey(x => x.Id); |
| | | 15 | | |
| | 3 | 16 | | token.Property(x => x.TokenHash).IsRequired(); |
| | 3 | 17 | | token.HasIndex(x => x.TokenHash).IsUnique(); |
| | | 18 | | |
| | 3 | 19 | | token.Property(x => x.ExpiresAt).IsRequired(); |
| | 3 | 20 | | token.Property(x => x.Used).HasDefaultValue(false); |
| | | 21 | | |
| | | 22 | | // Tokens are removed when their person is hard-deleted (UC-10). |
| | 3 | 23 | | token.HasOne(x => x.Person) |
| | 3 | 24 | | .WithMany(p => p.PasswordResetTokens) |
| | 3 | 25 | | .HasForeignKey(x => x.PersonId) |
| | 3 | 26 | | .IsRequired() |
| | 3 | 27 | | .OnDelete(DeleteBehavior.Cascade); |
| | 3 | 28 | | } |
| | | 29 | | } |