namespace CMSMicroservice.Domain.Entities;
//توکن Otp
public class OtpToken : BaseAuditableEntity
{
    //موبایل مقصد
    public string Mobile { get; set; }
    //مقصود
    public string Purpose { get; set; }
    //کد 
    public string Code { get; set; }
    //کد هش شده
    public string CodeHash { get; set; }
    //زمان انقضا
    public DateTime ExpiresAt { get; set; }
    //شمارش تلاش‌ها
    public int Attempts { get; set; }
    //موفق بود؟
    public bool IsUsed { get; set; }

    /// <summary>
    /// Checks if token is still valid (not used and not expired).
    /// Code verification should be done in the handler using IHashService.
    /// </summary>
    public bool IsValid()
    {
        return !IsUsed && DateTime.Now > ExpiresAt == false;
    }
}
