diff --git a/demo/WebAuthn.Net.Demo.Mvc/Controllers/PasswordlessController.cs b/demo/WebAuthn.Net.Demo.Mvc/Controllers/PasswordlessController.cs index ce3dd24..0bf6739 100644 --- a/demo/WebAuthn.Net.Demo.Mvc/Controllers/PasswordlessController.cs +++ b/demo/WebAuthn.Net.Demo.Mvc/Controllers/PasswordlessController.cs @@ -95,7 +95,8 @@ public async Task CompleteAuthentication( cancellationToken); if (authenticationCeremonyId is null) { - return BadRequest(); + ModelState.AddModelError("", "Authentication ceremony not found"); + return BadRequest(ModelState); } var result = await _authenticationCeremonyService.CompleteCeremonyAsync( @@ -106,7 +107,8 @@ public async Task CompleteAuthentication( cancellationToken); if (result.HasError) { - return BadRequest(); + ModelState.AddModelError("", "The authentication ceremony completed with an error"); + return BadRequest(ModelState); } var applicationUser = await _userService.FindAsync( @@ -115,7 +117,8 @@ public async Task CompleteAuthentication( cancellationToken); if (applicationUser is null) { - return BadRequest(); + ModelState.AddModelError("", "User not found"); + return BadRequest(ModelState); } var claims = new List diff --git a/demo/WebAuthn.Net.Demo.Mvc/Controllers/RegistrationController.cs b/demo/WebAuthn.Net.Demo.Mvc/Controllers/RegistrationController.cs index bbc2b64..f2a44ce 100644 --- a/demo/WebAuthn.Net.Demo.Mvc/Controllers/RegistrationController.cs +++ b/demo/WebAuthn.Net.Demo.Mvc/Controllers/RegistrationController.cs @@ -76,7 +76,8 @@ public async Task CompleteRegistration( cancellationToken); if (registrationCeremonyId is null) { - return BadRequest(); + ModelState.AddModelError("", "Registration ceremony not found"); + return BadRequest(ModelState); } var result = await _registrationCeremonyService.CompleteCeremonyAsync( @@ -88,7 +89,8 @@ public async Task CompleteRegistration( cancellationToken); if (result.HasError) { - return BadRequest(); + ModelState.AddModelError("", "The registration ceremony completed with an error"); + return BadRequest(ModelState); } await _registrationCeremonyHandleService.DeleteAsync(HttpContext, cancellationToken); diff --git a/demo/WebAuthn.Net.Demo.Mvc/Controllers/UsernamelessController.cs b/demo/WebAuthn.Net.Demo.Mvc/Controllers/UsernamelessController.cs index dfc4d31..33555ab 100644 --- a/demo/WebAuthn.Net.Demo.Mvc/Controllers/UsernamelessController.cs +++ b/demo/WebAuthn.Net.Demo.Mvc/Controllers/UsernamelessController.cs @@ -84,7 +84,8 @@ public async Task CompleteAuthentication( cancellationToken); if (authenticationCeremonyId is null) { - return BadRequest(); + ModelState.AddModelError("", "Authentication ceremony not found"); + return BadRequest(ModelState); } var result = await _authenticationCeremonyService.CompleteCeremonyAsync( @@ -95,7 +96,8 @@ public async Task CompleteAuthentication( cancellationToken); if (result.HasError) { - return BadRequest(); + ModelState.AddModelError("", "The authentication ceremony completed with an error"); + return BadRequest(ModelState); } var applicationUser = await _userService.FindAsync( @@ -104,7 +106,8 @@ public async Task CompleteAuthentication( cancellationToken); if (applicationUser is null) { - return BadRequest(); + ModelState.AddModelError("", "User not found"); + return BadRequest(ModelState); } var claims = new List