Skip to content

Commit

Permalink
Do not limit the error controller to a specific HTTP method
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchalet committed Sep 1, 2024
1 parent 44aed04 commit aa6733b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ namespace OpenIddict.Sandbox.AspNetCore.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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ namespace OpenIddict.Sandbox.AspNetCore.Server;

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 server, render the error details.
var response = HttpContext.GetOpenIddictServerResponse();
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());
}
}
2 changes: 1 addition & 1 deletion shared/OpenIddict.Extensions/OpenIddictHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ public Dictionary<string, StringValues> GetResults()
{
foreach (var entry in _expandingAccumulator)
{
_accumulator[entry.Key] = new StringValues(entry.Value.ToArray());
_accumulator[entry.Key] = new StringValues([.. entry.Value]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ public static ImmutableDictionary<string, string[]> GetDestinations(this ClaimsI
}
}

builder.Add(group.Key, destinations.ToArray());
builder.Add(group.Key, [.. destinations]);
}
}

Expand Down Expand Up @@ -697,7 +697,7 @@ public static ImmutableDictionary<string, string[]> GetDestinations(this ClaimsP
}
}

builder.Add(group.Key, destinations.ToArray());
builder.Add(group.Key, [.. destinations]);
}
}

Expand Down

0 comments on commit aa6733b

Please sign in to comment.