Developer 02 ff6d27df8e feat(DTOExtensions): Erstellt, um Erweiterungsmethoden für DTOs hinzuzufügen.
- IsTotpSecretExpired, IsTotpSecretInvalid und IsTotpSecretValid Erweiterungsmethoden für ReceiverReadDto hinzugefügt, um den Zustand des geheimen Schlüssels zu behandeln.
2024-12-10 20:32:09 +01:00

14 lines
593 B
C#

using EnvelopeGenerator.Application.DTOs.Receiver;
namespace EnvelopeGenerator.Application.Extensions
{
public static class DTOExtensions
{
public static bool IsTotpSecretExpired(this ReceiverReadDto dto, int minutesBeforeExpiration = 30)
=> dto.TotpExpiration < DateTime.Now.AddMinutes(minutesBeforeExpiration * -1);
public static bool IsTotpSecretInvalid(this ReceiverReadDto dto) => dto.IsTotpSecretExpired() || dto.TotpSecretkey is null;
public static bool IsTotpSecretValid(this ReceiverReadDto dto) => !dto.IsTotpSecretInvalid();
}
}