refactor(HomeController): Statische Eigenschaften SmsTotpStep und SmsFormat hinzugefügt.
This commit is contained in:
parent
80f9107e4e
commit
be44f9f436
@ -38,6 +38,8 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
private readonly IMessagingService _msgService;
|
||||
private readonly ICodeGenerator _codeGenerator;
|
||||
private readonly IReceiverService _rcvService;
|
||||
private static readonly int SmsTotpStep = 60 * 3;
|
||||
private static readonly string SmsFormat = "{0}";
|
||||
|
||||
public HomeController(EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IEnvelopeReceiverService envelopeReceiverService, IEnvelopeHistoryService historyService, IStringLocalizer<Resource> localizer, IConfiguration configuration, HtmlSanitizer sanitizer, Cultures cultures, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverReadOnlyService readOnlyService, IMessagingService messagingService, ICodeGenerator codeGenerator, IReceiverService receiverService)
|
||||
{
|
||||
@ -195,9 +197,9 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
if (viaSms)
|
||||
{
|
||||
//add date time cache
|
||||
var res = await _msgService.SendSmsCodeAsync(er_secret.PhoneNumber!, er_secret.Receiver.TotpSecretkey);
|
||||
var res = await _msgService.SendSmsCodeAsync(er_secret.PhoneNumber!, er_secret.Receiver!.TotpSecretkey!, SmsFormat);
|
||||
if (res.Ok)
|
||||
return View("EnvelopeLocked").WithData("CodeType", "smsCode").WithData("SmsExpiration", res.Expiration);
|
||||
return View("EnvelopeLocked").WithData("CodeType", "smsCode").WithData("SmsExpiration", _codeGenerator.GetTotpExpirationTime(SmsTotpStep));
|
||||
else if (!res.Allowed)
|
||||
return View("EnvelopeLocked").WithData("CodeType", "smsCode").WithData("SmsExpiration", res.AllowedAt);
|
||||
else
|
||||
@ -253,7 +255,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
if (er_secret.Receiver!.TotpSecretkey is null)
|
||||
throw new InvalidOperationException($"TotpSecretkey of DTO cannot validate without TotpSecretkey. Dto: {JsonConvert.SerializeObject(er_secret)}");
|
||||
|
||||
if (_codeGenerator.VerifyTotp(auth.SmsCode!, er_secret.Receiver.TotpSecretkey, step: 60 * 5))
|
||||
if (_codeGenerator.VerifyTotp(auth.SmsCode!, er_secret.Receiver.TotpSecretkey, step: SmsTotpStep))
|
||||
{
|
||||
Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
ViewData["ErrorMessage"] = _localizer[WebKey.WrongAccessCode].Value;
|
||||
@ -381,7 +383,8 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
return await _envRcvService.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId).ThenAsync(
|
||||
SuccessAsync: async (er) =>
|
||||
{ViewData["UserCulture"] = _cultures[UserLanguage];
|
||||
{
|
||||
ViewData["UserCulture"] = _cultures[UserLanguage];
|
||||
ViewData["UserCulture"] = _cultures[UserLanguage];
|
||||
return await _historyService.IsRejected(envelopeId: er.EnvelopeId)
|
||||
? View(er)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user