refactor(Receiver): Entfernt TotpExpiration aus allen DTOs und Entitäten.
This commit is contained in:
parent
9cdb1409c0
commit
fa36593b26
@ -4,7 +4,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace EnvelopeGenerator.Application.DTOs.Receiver
|
namespace EnvelopeGenerator.Application.DTOs.Receiver
|
||||||
{
|
{
|
||||||
public record ReceiverCreateDto([EmailAddress] string EmailAddress, string? TotpSecretkey = null, DateTime? TotpExpiration = null)
|
public record ReceiverCreateDto([EmailAddress] string EmailAddress, string? TotpSecretkey = null)
|
||||||
{
|
{
|
||||||
public string Signature => sha256HexOfMail.Value;
|
public string Signature => sha256HexOfMail.Value;
|
||||||
|
|
||||||
|
|||||||
@ -20,8 +20,5 @@ public record ReceiverReadDto(
|
|||||||
|
|
||||||
public string? TotpSecretkey { get; set; } = null;
|
public string? TotpSecretkey { get; set; } = null;
|
||||||
|
|
||||||
[TemplatePlaceholder("[TFA_QR_EXPIRATION]")]
|
|
||||||
public DateTime? TotpExpiration { get; set; } = null;
|
|
||||||
|
|
||||||
public DateTime? TfaRegDeadline { get; set; }
|
public DateTime? TfaRegDeadline { get; set; }
|
||||||
};
|
};
|
||||||
@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
namespace EnvelopeGenerator.Application.DTOs.Receiver;
|
namespace EnvelopeGenerator.Application.DTOs.Receiver;
|
||||||
|
|
||||||
public record ReceiverUpdateDto(int Id, string? TotpSecretkey = null, DateTime? TotpExpiration = null, DateTime? TfaRegDeadline = null) : IUnique<int>;
|
public record ReceiverUpdateDto(int Id, string? TotpSecretkey = null, DateTime? TfaRegDeadline = null) : IUnique<int>;
|
||||||
@ -164,14 +164,11 @@ namespace EnvelopeGenerator.Application.Services
|
|||||||
throw new ArgumentNullException(nameof(dto), $"TFA Qr Code cannot sent. Receiver information is missing. Envelope receiver dto is {JsonConvert.SerializeObject(dto)}");
|
throw new ArgumentNullException(nameof(dto), $"TFA Qr Code cannot sent. Receiver information is missing. Envelope receiver dto is {JsonConvert.SerializeObject(dto)}");
|
||||||
if (dto.Receiver.TotpSecretkey is null)
|
if (dto.Receiver.TotpSecretkey is null)
|
||||||
throw new ArgumentNullException(nameof(dto), $"TFA Qr Code cannot sent. Receiver.TotpSecretKey is null. Envelope receiver dto is {JsonConvert.SerializeObject(dto)}");
|
throw new ArgumentNullException(nameof(dto), $"TFA Qr Code cannot sent. Receiver.TotpSecretKey is null. Envelope receiver dto is {JsonConvert.SerializeObject(dto)}");
|
||||||
if (dto.Receiver.TotpExpiration is null)
|
|
||||||
throw new ArgumentNullException(nameof(dto), $"TFA Qr Code cannot sent. Receiver.TotpExpiration is null. Envelope receiver dto is {JsonConvert.SerializeObject(dto)}");
|
|
||||||
|
|
||||||
var totp_qr_64 = _authenticator.GenerateTotpQrCode(userEmail: dto.Receiver.EmailAddress, secretKey: dto.Receiver.TotpSecretkey).ToBase64String();
|
var totp_qr_64 = _authenticator.GenerateTotpQrCode(userEmail: dto.Receiver.EmailAddress, secretKey: dto.Receiver.TotpSecretkey).ToBase64String();
|
||||||
return SendAsync(dto, EmailTemplateType.TotpSecret, new()
|
return SendAsync(dto, EmailTemplateType.TotpSecret, new()
|
||||||
{
|
{
|
||||||
{"[TFA_QR_CODE]", totp_qr_64 },
|
{"[TFA_QR_CODE]", totp_qr_64 },
|
||||||
{"[TFA_EXPIRATION]", dto.Receiver.TotpExpiration }
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,9 +27,6 @@ public class Receiver : IUnique<int>
|
|||||||
[Column("TOTP_SECRET_KEY", TypeName = "nvarchar(MAX)")]
|
[Column("TOTP_SECRET_KEY", TypeName = "nvarchar(MAX)")]
|
||||||
public string? TotpSecretkey { get; set; }
|
public string? TotpSecretkey { get; set; }
|
||||||
|
|
||||||
[Column("TOTP_EXPIRATION", TypeName = "datetime")]
|
|
||||||
public DateTime? TotpExpiration { get; set; }
|
|
||||||
|
|
||||||
[Column("TFA_REG_DEADLINE", TypeName = "datetime")]
|
[Column("TFA_REG_DEADLINE", TypeName = "datetime")]
|
||||||
public DateTime? TfaRegDeadline { get; set; }
|
public DateTime? TfaRegDeadline { get; set; }
|
||||||
|
|
||||||
|
|||||||
@ -173,7 +173,6 @@ public class HomeController : ViewControllerBase
|
|||||||
{
|
{
|
||||||
return View("EnvelopeLocked")
|
return View("EnvelopeLocked")
|
||||||
.WithData("CodeType", "authenticatorCode")
|
.WithData("CodeType", "authenticatorCode")
|
||||||
.WithData("QRCodeExpiration", er_secret.Receiver?.TotpExpiration)
|
|
||||||
.WithData("TfaRegDeadline", er_secret.Receiver?.TfaRegDeadline);
|
.WithData("TfaRegDeadline", er_secret.Receiver?.TfaRegDeadline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +199,6 @@ public class HomeController : ViewControllerBase
|
|||||||
if (rcv.TotpSecretkey is null)
|
if (rcv.TotpSecretkey is null)
|
||||||
{
|
{
|
||||||
rcv.TotpSecretkey = _authenticator.GenerateTotpSecretKey();
|
rcv.TotpSecretkey = _authenticator.GenerateTotpSecretKey();
|
||||||
rcv.TotpExpiration = DateTime.Now.AddMonths(1);
|
|
||||||
await _rcvService.UpdateAsync(rcv);
|
await _rcvService.UpdateAsync(rcv);
|
||||||
}
|
}
|
||||||
return await TFAViewAsync(auth.UserSelectSMS, er_secret, envelopeReceiverId);
|
return await TFAViewAsync(auth.UserSelectSMS, er_secret, envelopeReceiverId);
|
||||||
|
|||||||
@ -58,7 +58,6 @@ public class TFARegController : ViewControllerBase
|
|||||||
|
|
||||||
// Generate QR code as base 64
|
// Generate QR code as base 64
|
||||||
rcv!.TotpSecretkey = _authenticator.GenerateTotpSecretKey();
|
rcv!.TotpSecretkey = _authenticator.GenerateTotpSecretKey();
|
||||||
rcv.TotpExpiration = DateTime.Now.AddMonths(1);
|
|
||||||
await _rcvService.UpdateAsync(rcv);
|
await _rcvService.UpdateAsync(rcv);
|
||||||
var totp_qr_64 = _authenticator.GenerateTotpQrCode(userEmail: rcv.EmailAddress, secretKey: rcv.TotpSecretkey).ToBase64String();
|
var totp_qr_64 = _authenticator.GenerateTotpQrCode(userEmail: rcv.EmailAddress, secretKey: rcv.TotpSecretkey).ToBase64String();
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
bool viaAuthenticator = codeType == "authenticatorCode";
|
bool viaAuthenticator = codeType == "authenticatorCode";
|
||||||
bool viaTFA = viaSms || viaAuthenticator;
|
bool viaTFA = viaSms || viaAuthenticator;
|
||||||
DateTime? smsExpiration = ViewData["SmsExpiration"] is DateTime _smsExpiration ? _smsExpiration : null;
|
DateTime? smsExpiration = ViewData["SmsExpiration"] is DateTime _smsExpiration ? _smsExpiration : null;
|
||||||
DateTime? qrCodeExpiration = ViewData["QRCodeExpiration"] is DateTime _qrCodeExpiration ? _qrCodeExpiration : null;
|
|
||||||
bool tfaEnabled = ViewData["TFAEnabled"] is bool _tfaEnabled && _tfaEnabled;
|
bool tfaEnabled = ViewData["TFAEnabled"] is bool _tfaEnabled && _tfaEnabled;
|
||||||
bool hasPhoneNumber = ViewData["HasPhoneNumber"] is bool _hasPhoneNumber && _hasPhoneNumber;
|
bool hasPhoneNumber = ViewData["HasPhoneNumber"] is bool _hasPhoneNumber && _hasPhoneNumber;
|
||||||
var envelopeKey = ViewData["EnvelopeKey"] as string;
|
var envelopeKey = ViewData["EnvelopeKey"] as string;
|
||||||
@ -46,7 +45,7 @@
|
|||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
<section class="text-center">
|
<section class="text-center">
|
||||||
<p>@_localizer[WebKey.Formats.LockedBody.Format(codeKeyName)].Value.Format(qrCodeExpiration.ToString())</p>
|
<p>@_localizer[WebKey.Formats.LockedBody.Format(codeKeyName)].Value</p>
|
||||||
</section>
|
</section>
|
||||||
<div class="row m-0 p-0">
|
<div class="row m-0 p-0">
|
||||||
<div class="access-code-panel justify-content-center align-items-center p-0 m-0">
|
<div class="access-code-panel justify-content-center align-items-center p-0 m-0">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user