diff --git a/samples/Dantooine/Dantooine.Server/Controllers/ErrorController.cs b/samples/Dantooine/Dantooine.Server/Controllers/ErrorController.cs index 94e00f07..86e4b028 100644 --- a/samples/Dantooine/Dantooine.Server/Controllers/ErrorController.cs +++ b/samples/Dantooine/Dantooine.Server/Controllers/ErrorController.cs @@ -4,30 +4,28 @@ * the license and the contributors participating to this project. */ +using Dantooine.Server.ViewModels.Shared; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Mvc; -using Dantooine.Server.ViewModels.Shared; namespace Dantooine.Server.Controllers; public class ErrorController : Controller { - [Route("error")] - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true), Route("~/error")] public IActionResult Error() { - // If the error was not caused by an invalid - // OIDC request, display a generic error page. + // If the error originated from the OpenIddict server, render the error details. var response = HttpContext.GetOpenIddictServerResponse(); - if (response == null) + if (response is not null) { - return View(new ErrorViewModel()); + return View(new ErrorViewModel + { + Error = response.Error, + ErrorDescription = response.ErrorDescription + }); } - return View(new ErrorViewModel - { - Error = response.Error, - ErrorDescription = response.ErrorDescription - }); + return View(new ErrorViewModel()); } } diff --git a/samples/Matty/Matty.Server/Controllers/ErrorController.cs b/samples/Matty/Matty.Server/Controllers/ErrorController.cs index 0d5bbdb1..656930a4 100644 --- a/samples/Matty/Matty.Server/Controllers/ErrorController.cs +++ b/samples/Matty/Matty.Server/Controllers/ErrorController.cs @@ -4,30 +4,28 @@ * the license and the contributors participating to this project. */ +using Matty.Server.ViewModels.Shared; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Mvc; -using Matty.Server.ViewModels.Shared; namespace Matty.Server.Controllers; public class ErrorController : Controller { - [Route("error")] - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true), Route("~/error")] public IActionResult Error() { - // If the error was not caused by an invalid - // OIDC request, display a generic error page. + // If the error originated from the OpenIddict server, render the error details. var response = HttpContext.GetOpenIddictServerResponse(); - if (response == null) + if (response is not null) { - return View(new ErrorViewModel()); + return View(new ErrorViewModel + { + Error = response.Error, + ErrorDescription = response.ErrorDescription + }); } - return View(new ErrorViewModel - { - Error = response.Error, - ErrorDescription = response.ErrorDescription - }); + return View(new ErrorViewModel()); } } diff --git a/samples/Velusia/Velusia.Client/Controllers/ErrorController.cs b/samples/Velusia/Velusia.Client/Controllers/ErrorController.cs index 862b3d83..19491982 100644 --- a/samples/Velusia/Velusia.Client/Controllers/ErrorController.cs +++ b/samples/Velusia/Velusia.Client/Controllers/ErrorController.cs @@ -6,21 +6,20 @@ namespace Velusia.Client; public class ErrorController : Controller { - [HttpGet, HttpPost, Route("~/error")] + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true), Route("~/error")] public IActionResult Error() { - // If the error was not caused by an invalid - // OIDC request, display a generic error page. + // If the error originated from the OpenIddict client, render the error details. var response = HttpContext.GetOpenIddictClientResponse(); - if (response is null) + if (response is not null) { - return View(new ErrorViewModel()); + return View(new ErrorViewModel + { + Error = response.Error, + ErrorDescription = response.ErrorDescription + }); } - return View(new ErrorViewModel - { - Error = response.Error, - ErrorDescription = response.ErrorDescription - }); + return View(new ErrorViewModel()); } } diff --git a/samples/Velusia/Velusia.Server/Controllers/ErrorController.cs b/samples/Velusia/Velusia.Server/Controllers/ErrorController.cs index 95f4c6e9..dca855d4 100644 --- a/samples/Velusia/Velusia.Server/Controllers/ErrorController.cs +++ b/samples/Velusia/Velusia.Server/Controllers/ErrorController.cs @@ -12,22 +12,20 @@ namespace Velusia.Server.Controllers; public class ErrorController : Controller { - [Route("error")] - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true), Route("~/error")] public IActionResult Error() { - // If the error was not caused by an invalid - // OIDC request, display a generic error page. + // If the error originated from the OpenIddict server, render the error details. var response = HttpContext.GetOpenIddictServerResponse(); - if (response == null) + if (response is not null) { - return View(new ErrorViewModel()); + return View(new ErrorViewModel + { + Error = response.Error, + ErrorDescription = response.ErrorDescription + }); } - return View(new ErrorViewModel - { - Error = response.Error, - ErrorDescription = response.ErrorDescription - }); + return View(new ErrorViewModel()); } }