Add rockstar friendly error 403

This commit is contained in:
nicolas.dorier 2022-01-07 19:46:38 +09:00
parent 098879585a
commit 81c1cc6728
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
3 changed files with 21 additions and 1 deletions

View file

@ -13,7 +13,7 @@ namespace BTCPayServer.Controllers
{ {
if (statusCode.HasValue) if (statusCode.HasValue)
{ {
var specialPages = new[] { 404, 406, 417, 429, 500, 502 }; var specialPages = new[] { 404, 406, 417, 429, 500, 502, 403 };
if (specialPages.Any(a => a == statusCode.Value)) if (specialPages.Any(a => a == statusCode.Value))
{ {
var viewName = statusCode.ToString(); var viewName = statusCode.ToString();
@ -24,5 +24,10 @@ namespace BTCPayServer.Controllers
} }
return this.StatusCode(statusCode.Value); return this.StatusCode(statusCode.Value);
} }
public IActionResult Denied()
{
return Handle(403);
}
} }
} }

View file

@ -75,6 +75,7 @@ namespace BTCPayServer.Hosting
services.PostConfigure<CookieAuthenticationOptions>(IdentityConstants.ApplicationScheme, opt => services.PostConfigure<CookieAuthenticationOptions>(IdentityConstants.ApplicationScheme, opt =>
{ {
opt.LoginPath = "/login"; opt.LoginPath = "/login";
opt.AccessDeniedPath = "/Error/Denied";
}); });
services.Configure<SecurityStampValidatorOptions>(opts => services.Configure<SecurityStampValidatorOptions>(opts =>

View file

@ -0,0 +1,14 @@
@{
Layout = "_LayoutError";
ViewData["Title"] = "403 - Denied";
}
What are you looking at?
<br /><br />
<a href="https://twitter.com/r0ckstardev" target="_blank" rel="noreferrer noopener">
<img src="~/img/errorpages/429_rockstardev.jpg" alt="Vin is angry because you caused 403" title="Move away that cursor" asp-append-version="true" />
</a>
<br /><br />
It's not your business.
<br /><br />
Slowly <a href="/">navigate back to home</a>.