Skip to content

Commit 86cf3e4

Browse files
committed
VPR-54 fix(scheduler): render Razor 403 view for dashboard auth denials
Hangfire's dashboard middleware writes a bare 403 directly to the response when our IDashboardAuthorizationFilter returns false, which bypasses cookie auth's AccessDeniedPath and lands the user on the browser's default error page. Add UseStatusCodePagesWithReExecute so any bare 4xx/5xx status code re-runs through HomeController.Error and the existing /Views/Home/403.cshtml view. Applies globally — also catches stray bare 404s from any other middleware. Status code is preserved on the response (browser still sees 403); only the body is replaced with the rendered view.
1 parent 722ca6d commit 86cf3e4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

web/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ void RegisterDbContext<TContext>(string connectionStringKey) where TContext : Db
388388

389389
}
390390

391+
// Re-execute bare status-code responses (403, 404, etc.) through HomeController.Error
392+
// so middleware that writes raw status codes — e.g. Hangfire's dashboard middleware
393+
// when our auth filter denies — gets the same Razor error view as the rest of the app.
394+
app.UseStatusCodePagesWithReExecute("/Error/{0}");
395+
391396
// In development, set up Vite proxy BEFORE rewrite rules so it can handle .ts/.js files
392397
if (app.Environment.IsDevelopment())
393398
{

0 commit comments

Comments
 (0)