refactor(HomeController): Aktualisiert, um zu prüfen, ob der UserSelectSMS-Status null ist.

This commit is contained in:
Developer 02 2024-12-10 18:24:29 +01:00
parent bed51992d2
commit 137d8e09d4

View File

@ -19,6 +19,7 @@ using Ganss.Xss;
using Newtonsoft.Json;
using EnvelopeGenerator.Application.DTOs;
using DigitalData.Core.Client;
using System.Text.Json;
namespace EnvelopeGenerator.Web.Controllers
{
@ -217,9 +218,20 @@ namespace EnvelopeGenerator.Web.Controllers
await _historyService.RecordAsync(er_secret.EnvelopeId, er_secret.Receiver!.EmailAddress, Constants.EnvelopeStatus.AccessCodeCorrect);
//check if the user has phone is added
if (er_secret.HasPhoneNumber)
if (er_secret.TFAEnabled)
{
return await SendSmsView();
if (auth.UserSelectSMS is bool userSelectSMS)
{
if(userSelectSMS)
return await SendSmsView();
}
else
{
// if If TFA is enabled but UserSelectSMS is null, there is an unauthorized request(e.g. via an application like postman)
Response.StatusCode = StatusCodes.Status401Unauthorized;
_logger.LogError("TFA is enabled but UserSelectSMS is null. In this case there is an unauthorized request (for example via an application like postman). Form data: {form}", JsonConvert.SerializeObject(auth));
return this.ViewInnerServiceError();
}
}
}
else if (auth.HasSmsCode)