Activities of "utku.birkan"

Hi, I am trying to implement a custom 403 HTTP error page using Angular by providing an HTTP_ERROR_HANDLER function similar to the one described in the documentation. My implementation is given below.

// http-error-handler.ts
export function handleHttpErrors(injector: Injector, httpError: HttpErrorResponse) {
  if (httpError.status === 403) {
    const router = injector.get(Router);
    router.navigateByUrl('/unauthorized');
    return;
  }

  return throwError(httpError);
}

// app.module.ts
@NgModule({
  ...,
  providers: [
    ...,
    {
      provide: HTTP_ERROR_HANDLER,
      useValue: handleHttpErrors,
    },
  ]
})
export class AppModule {}

Before providing this error, UserFriendlyExceptions on the server side were handled via popups in the frontend. Now, each UserFriendlyException is captured by handleHttpErrors function as an HttpErrorResponse with status 403. We want to retain the previous 403 page behavior while using our new layout for actual, permission related 403 errors.

Relevant info:

  • ABP Framework version: v5.3.x
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
Showing 1 to 1 of 1 entries
Made with ❤️ on ABP v9.2.0-preview. Updated on January 24, 2025, 10:25