refactor(CodeGenerator): umbenannt in Authenticator

This commit is contained in:
Developer 02
2025-02-03 09:58:57 +01:00
parent bbd03615e1
commit 808a02968b
7 changed files with 22 additions and 22 deletions

View File

@@ -16,14 +16,14 @@ public class EnvelopeSmsHandler : IEnvelopeSmsHandler
private readonly IDistributedCache _dCache;
private readonly ICodeGenerator _codeGenerator;
private readonly IAuthenticator _authenticator;
public EnvelopeSmsHandler(ISmsSender sender, IOptions<TotpSmsParams> totpSmsParamsOptions, IDistributedCache distributedCache, ICodeGenerator codeGenerator)
public EnvelopeSmsHandler(ISmsSender sender, IOptions<TotpSmsParams> totpSmsParamsOptions, IDistributedCache distributedCache, IAuthenticator authenticator)
{
_sender = sender;
_totpSmsParams = totpSmsParamsOptions.Value;
_dCache = distributedCache;
_codeGenerator = codeGenerator;
_authenticator = authenticator;
}
/// <summary>
@@ -42,12 +42,12 @@ public class EnvelopeSmsHandler : IEnvelopeSmsHandler
else
{
var new_expiration = DateTime.Now.AddSeconds(_totpSmsParams.TotpStep);
var totp = _codeGenerator.GenerateTotp(er_secret.Receiver!.TotpSecretkey!, _totpSmsParams.TotpStep);
var totp = _authenticator.GenerateTotp(er_secret.Receiver!.TotpSecretkey!, _totpSmsParams.TotpStep);
var msg = string.Format(_totpSmsParams.Format, totp, new_expiration.ToString(_totpSmsParams.Expiration.Format, _totpSmsParams.Expiration.CultureInfo));
return (await _sender.SendSmsAsync(er_secret.PhoneNumber!, msg), new_expiration);
}
}
public bool VerifyTotp(string totpCode, string secretKey) => _codeGenerator
public bool VerifyTotp(string totpCode, string secretKey) => _authenticator
.VerifyTotp(totpCode, secretKey, _totpSmsParams.TotpStep, _totpSmsParams.TotpVerificationWindow);
}