| | | 1 | | using System.ComponentModel.DataAnnotations; |
| | | 2 | | using ArturRios.Data.Relational.Core.Entities; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Heimdall.Domain.Entities; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// A time-limited, single-use token issued to verify a person's email address. Never addressed |
| | | 8 | | /// by its internal <see cref="Entity{TKey}.Id" />; the caller-facing reference is the random token |
| | | 9 | | /// string delivered by email, so it has no <c>PublicId</c>. |
| | | 10 | | /// </summary> |
| | | 11 | | public class EmailVerificationToken : Entity<long>, IPersonToken |
| | | 12 | | { |
| | | 13 | | /// <summary>Foreign key to the associated <see cref="Person" /> (internal Id). Required.</summary> |
| | 199 | 14 | | public long PersonId { get; set; } |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// SHA-256 of the token that was emailed, as lowercase hex, for the same reason as on |
| | | 18 | | /// <see cref="PasswordResetToken" /> (Threat Model TH-14): a verification token confirms an |
| | | 19 | | /// address, and an address is what a password reset is addressed to. Written and compared |
| | | 20 | | /// through <c>SingleUseTokenHash</c>. |
| | | 21 | | /// </summary> |
| | | 22 | | [MaxLength(64)] |
| | 347 | 23 | | public string TokenHash { get; set; } = string.Empty; |
| | | 24 | | |
| | | 25 | | /// <summary>Expiration timestamp, after which the token is rejected.</summary> |
| | 212 | 26 | | public DateTime ExpiresAt { get; set; } |
| | | 27 | | |
| | | 28 | | /// <summary>Whether the token has already been consumed.</summary> |
| | 274 | 29 | | public bool Used { get; set; } |
| | | 30 | | |
| | | 31 | | // Navigation properties |
| | | 32 | | |
| | | 33 | | /// <summary>The person this token was issued for.</summary> |
| | 126 | 34 | | public Person Person { get; set; } = null!; |
| | | 35 | | } |