feat(HomeController): Funktion zur Überprüfung des Authenticator-Codes hinzugefügt.
This commit is contained in:
parent
27db664b4d
commit
c41d5c4a76
@ -4,7 +4,7 @@ namespace EnvelopeGenerator.Extensions
|
||||
{
|
||||
public static class StringExtension
|
||||
{
|
||||
public static bool IsValidTotp(string totp, string secret)
|
||||
public static bool IsValidTotp(this string totp, string secret)
|
||||
{
|
||||
var secret_bytes = Base32Encoding.ToBytes(secret);
|
||||
var secret_totp = new Totp(secret_bytes);
|
||||
|
||||
@ -19,7 +19,6 @@ using Ganss.Xss;
|
||||
using Newtonsoft.Json;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using DigitalData.Core.Client;
|
||||
using System.Text.Json;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers
|
||||
@ -257,6 +256,15 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
return await TFAView(viaSms: true);
|
||||
}
|
||||
}
|
||||
else if (auth.HasAuthenticatorCode)
|
||||
{
|
||||
if (!auth.AuthenticatorCode!.IsValidTotp(er_secret.Receiver!.TotpSecretkey!))
|
||||
{
|
||||
Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
ViewData["ErrorMessage"] = _localizer[WebKey.WrongAccessCode].Value;
|
||||
return await TFAView(viaSms: false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user