- IsTotpSecretExpired, IsTotpSecretInvalid und IsTotpSecretValid Erweiterungsmethoden für ReceiverReadDto hinzugefügt, um den Zustand des geheimen Schlüssels zu behandeln.
14 lines
593 B
C#
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();
|
|
}
|
|
} |