aboutsummaryrefslogtreecommitdiff
path: root/VNLib.Plugins.Essentials.Accounts/MFA
diff options
context:
space:
mode:
Diffstat (limited to 'VNLib.Plugins.Essentials.Accounts/MFA')
-rw-r--r--VNLib.Plugins.Essentials.Accounts/MFA/MFAConfig.cs4
-rw-r--r--VNLib.Plugins.Essentials.Accounts/MFA/UserMFAExtensions.cs16
2 files changed, 7 insertions, 13 deletions
diff --git a/VNLib.Plugins.Essentials.Accounts/MFA/MFAConfig.cs b/VNLib.Plugins.Essentials.Accounts/MFA/MFAConfig.cs
index 8e85e65..f04693e 100644
--- a/VNLib.Plugins.Essentials.Accounts/MFA/MFAConfig.cs
+++ b/VNLib.Plugins.Essentials.Accounts/MFA/MFAConfig.cs
@@ -34,9 +34,9 @@ namespace VNLib.Plugins.Essentials.Accounts.MFA
{
internal class MFAConfig
{
- public byte[]? MFASecret { get; set; } = null;
+ public byte[]? MFASecret { get; set; }
- public bool TOTPEnabled { get; } = false;
+ public bool TOTPEnabled { get; }
public string? IssuerName { get; }
public TimeSpan TOTPPeriod { get; }
public HashAlg TOTPAlg { get; }
diff --git a/VNLib.Plugins.Essentials.Accounts/MFA/UserMFAExtensions.cs b/VNLib.Plugins.Essentials.Accounts/MFA/UserMFAExtensions.cs
index 3ebb6dd..6675a31 100644
--- a/VNLib.Plugins.Essentials.Accounts/MFA/UserMFAExtensions.cs
+++ b/VNLib.Plugins.Essentials.Accounts/MFA/UserMFAExtensions.cs
@@ -228,18 +228,12 @@ namespace VNLib.Plugins.Essentials.Accounts.MFA
MFAConfig mfa = new(conf);
//Recover secret from config and dangerous 'lazy load'
- _ = pbase.TryGetSecretAsync("mfa_secret").ContinueWith(t => {
-
- if(t.IsFaulted)
- {
- pbase.Log.Error(t.Exception!.InnerException, "Failed to load MFA signing secret");
- }
- else
- {
- mfa.MFASecret = t.Result != null ? Convert.FromBase64String(t.Result) : null;
- }
+ _ = pbase.DeferTask(async () =>
+ {
+ string? secret = await pbase.TryGetSecretAsync("mfa_secret");
+ mfa.MFASecret = secret != null ? Convert.FromBase64String(secret) : null;
});
-
+
return mfa;
}
//Return new lazy for