feat(TFARegController): Try-Catch zur Methode reg'e hinzugefügt.

- Ausnahme ist so eingestellt, dass sie protokolliert wird.
This commit is contained in:
Developer 02
2025-02-06 19:31:50 +01:00
parent 95785e8c8b
commit 9cdb1409c0
4 changed files with 45 additions and 60 deletions

View File

@@ -197,12 +197,11 @@ public class HomeController : ViewControllerBase
if (er_secret.Envelope!.TFAEnabled)
{
var rcv = er_secret.Receiver;
if (rcv.IsTotpSecretInvalid())
if (rcv.TotpSecretkey is null)
{
rcv.TotpSecretkey = _authenticator.GenerateTotpSecretKey();
rcv.TotpExpiration = DateTime.Now.AddMonths(1);
await _rcvService.UpdateAsync(rcv);
await _mailService.SendTFAQrCodeAsync(er_secret);
}
return await TFAViewAsync(auth.UserSelectSMS, er_secret, envelopeReceiverId);
}
@@ -229,7 +228,7 @@ public class HomeController : ViewControllerBase
[NonAction]
private async Task<IActionResult?> HandleAuthenticatorAsync(Auth auth, EnvelopeReceiverSecretDto er_secret, string envelopeReceiverId)
{
if (er_secret.Receiver!.IsTotpInvalid(totp: auth.AuthenticatorCode!))
if (er_secret.Receiver!.TotpSecretkey is null)
{
Response.StatusCode = StatusCodes.Status401Unauthorized;
ViewData["ErrorMessage"] = _localizer[WebKey.WrongAccessCode].Value;