Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not limit the error controller to a specific HTTP method #2171

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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