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.
This commit is contained in:
Developer 02
2024-12-10 20:32:09 +01:00
parent 76bd1a102f
commit ff6d27df8e
2 changed files with 15 additions and 2 deletions

View File

@@ -0,0 +1,14 @@
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();
}
}

View File

@@ -1,5 +1,4 @@
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver; using EnvelopeGenerator.Domain.HttpResponse;
using EnvelopeGenerator.Domain.HttpResponse;
namespace EnvelopeGenerator.Application.Extensions namespace EnvelopeGenerator.Application.Extensions
{ {