feat(HomeController): Aktualisiert, um SMS über zu senden.

- Unnötige Parameter in SmsParams entfernt.
 - Code-Sendefunktion von IMessagingService entfernt.
 - GetTotpExpirationTime Methode im CodeGenerator entfernt.
This commit is contained in:
Developer 02
2025-01-27 17:09:23 +01:00
parent cf300d3ade
commit 6abc17c3bf
8 changed files with 30 additions and 42 deletions

View File

@@ -67,10 +67,5 @@ namespace EnvelopeGenerator.Application.Services
public bool VerifyTotp(string totpCode, string secretKey, int step = 30, VerificationWindow? window = null)
=> new Totp(Base32Encoding.ToBytes(secretKey), step).VerifyTotp(totpCode, out _, window);
public bool GetTotpExpirationTime(int step = 30)
{
throw new NotImplementedException();
}
}
}

View File

@@ -16,17 +16,14 @@ public class GtxMessagingService : IMessagingService
private readonly IMapper _mapper;
private readonly ICodeGenerator _codeGen;
public string ServiceProvider { get; }
public GtxMessagingService(IHttpClientService<SmsParams> smsClient, IOptions<SmsParams> smsParamsOptions, IMapper mapper, ICodeGenerator codeGenerator)
public GtxMessagingService(IHttpClientService<SmsParams> smsClient, IOptions<SmsParams> smsParamsOptions, IMapper mapper)
{
_smsClient = smsClient;
_smsParams = smsParamsOptions.Value;
_mapper = mapper;
ServiceProvider = GetType().Name.Replace("Service", string.Empty);
_codeGen = codeGenerator;
}
public async Task<SmsResponse> SendSmsAsync(string recipient, string message)
@@ -39,11 +36,4 @@ public class GtxMessagingService : IMessagingService
.ThenAsync(res => res.Json<GtxMessagingResponse>())
.ThenAsync(_mapper.Map<SmsResponse>);
}
public async Task<SmsResponse> SendSmsCodeAsync(string recipient, string secretKey, string? messageFormat = null)
{
var code = _codeGen.GenerateTotp(secretKey, _smsParams.SmsTotpStep);
var message = string.Format(messageFormat ?? _smsParams.DefaultTotpMessageFormat, code);
return await SendSmsAsync(recipient: recipient, message: message);
}
}