aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-09-02 01:30:07 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-09-02 01:30:07 -0400
commit8f259eb09406d3f514a741873c2e16f2cc6d9306 (patch)
treedee1fbdd7219d902466e3d9adaa7dcc08226095f
parent48632913da47d77602c8e65275eaa24752258cf9 (diff)
push pending changes
-rw-r--r--plugins/VNLib.Plugins.Essentials.Accounts/src/Endpoints/PkiLoginEndpoint.cs22
-rw-r--r--plugins/VNLib.Plugins.Essentials.Accounts/src/MFA/Otp/UserOtpMfaExtensions.cs3
2 files changed, 22 insertions, 3 deletions
diff --git a/plugins/VNLib.Plugins.Essentials.Accounts/src/Endpoints/PkiLoginEndpoint.cs b/plugins/VNLib.Plugins.Essentials.Accounts/src/Endpoints/PkiLoginEndpoint.cs
index 7d8e9d5..7f34b50 100644
--- a/plugins/VNLib.Plugins.Essentials.Accounts/src/Endpoints/PkiLoginEndpoint.cs
+++ b/plugins/VNLib.Plugins.Essentials.Accounts/src/Endpoints/PkiLoginEndpoint.cs
@@ -216,6 +216,24 @@ namespace VNLib.Plugins.Essentials.Accounts.Endpoints
//Close response, user is now logged-in
return VirtualOk(entity, webm);
}
+ catch(JsonException jse)
+ {
+ //Invalidate incase it was set before the exception was raised
+ entity.InvalidateLogin();
+
+ webm.Errors = new ValidationErrorMessage[1]
+ {
+ new()
+ {
+ ErrorMessage = jse.Message,
+ PropertyName = "login",
+ }
+ };
+
+ webm.Result = "Please verify your login token and try again.";
+
+ return VirtualClose(entity, webm, HttpStatusCode.UnprocessableEntity);
+ }
catch
{
/*
@@ -290,7 +308,7 @@ namespace VNLib.Plugins.Essentials.Accounts.Endpoints
using IUser? user = await _users.GetUserFromIDAsync(entity.Session.UserID, entity.EventCancellation);
//Confirm not null, this should only happen if user is removed from table while still logged in
- if(webm.Assert(user != null, "You may not configure PKI authentication"))
+ if(webm.Assert(user != null, "You may not configure OTP authentication"))
{
return VirtualOk(entity, webm);
}
@@ -331,7 +349,7 @@ namespace VNLib.Plugins.Essentials.Accounts.Endpoints
//publish changes
await user.ReleaseAsync();
- webm.Result = "Successfully updated your PKI authentication method";
+ webm.Result = "Successfully updated your OTP authentication method";
webm.Success = true;
return VirtualOk(entity, webm);
}
diff --git a/plugins/VNLib.Plugins.Essentials.Accounts/src/MFA/Otp/UserOtpMfaExtensions.cs b/plugins/VNLib.Plugins.Essentials.Accounts/src/MFA/Otp/UserOtpMfaExtensions.cs
index 97b1807..5ad414e 100644
--- a/plugins/VNLib.Plugins.Essentials.Accounts/src/MFA/Otp/UserOtpMfaExtensions.cs
+++ b/plugins/VNLib.Plugins.Essentials.Accounts/src/MFA/Otp/UserOtpMfaExtensions.cs
@@ -91,7 +91,8 @@ namespace VNLib.Plugins.Essentials.Accounts.MFA.Otp
/*
* Since multiple keys can be stored, we need to recover the key that matches the desired key id
*/
- OtpAuthPublicKey? pub = user.OtpGetAllPublicKeys()?.FirstOrDefault(p => string.Equals(keyId, p.KeyId, StringComparison.Ordinal));
+ OtpAuthPublicKey? pub = user.OtpGetAllPublicKeys()
+ ?.FirstOrDefault(p => string.Equals(keyId, p.KeyId, StringComparison.Ordinal));
if (pub == null)
{