Skipping modal window from HttpErrorHandle in AuthInterceptor

9 views
Skip to first unread message

Take Back

unread,
Sep 20, 2019, 12:47:42 AM9/20/19
to Angular and AngularJS discussion

I have HttpErrorInterceptor and AuthInterceptor. Both of them are handling error code 400. The problem occurs while I'm trying to refresh the jwt token and the backend throws a bad request because either the refresh token has expired or it's invalid. In case that bad request happens on /api/token/refresh, I just want to log out the user and suppress all errors. I added an additional header which is supposed to skip the error modal window in HttpErrorInterceptor but the problem is that the actual error happens before the skip code and in the end that annoying modal window message appears.

If you look at the image below, you will see that this.authService.logout() was executed and right after it the HTTP Interceptor Skip (from HttpErrorInterceptor) and the actual error was displayed above them.


picture.png


How can I suppress all error messages for /api/token/refresh (this.authService.refreshToken()), so when it fails, it wouldn't pop that modal window up with error code 400?

https://stackblitz.com/edit/angular-dziwbx


Take Back

unread,
Sep 20, 2019, 12:47:42 AM9/20/19
to Angular and AngularJS discussion

Take Back

unread,
Sep 20, 2019, 12:47:42 AM9/20/19
to Angular and AngularJS discussion

I have HttpErrorInterceptor and AuthInterceptor. Both of them are handling error code 400. The problem occurs while I'm trying to refresh the jwt token and the backend throws a bad request because either the refresh token has expired or it's invalid. In case that bad request happens on /api/token/refresh, I just want to log out the user and suppress all errors. I added an additional header which is supposed to skip the error modal window in HttpErrorInterceptor but the problem is that the actual error happens before the skip code and in the end that annoying modal window message appears.

If you look at the image below, you will see that this.authService.logout() was executed and right after it the HTTP Interceptor Skip (from HttpErrorInterceptor) and the actual error was displayed above them.


Take Back

unread,
Sep 20, 2019, 12:47:42 AM9/20/19
to Angular and AngularJS discussion

Take Back

unread,
Sep 20, 2019, 12:47:42 AM9/20/19
to Angular and AngularJS discussion

Take Back

unread,
Sep 20, 2019, 12:47:42 AM9/20/19
to Angular and AngularJS discussion

I have HttpErrorInterceptor and AuthInterceptor. Both of them are handling error code 400. The problem occurs while I'm trying to refresh the jwt token and the backend throws a bad request because either the refresh token has expired or it's invalid. In case that bad request happens on /api/token/refresh, I just want to log out the user and suppress all errors. I added an additional header which is supposed to skip the error modal window in HttpErrorInterceptor but the problem is that the actual error happens before the skip code and in the end that annoying modal window message appears.

If you look at the image below, you will see that this.authService.logout() was executed and right after it the HTTP Interceptor Skip (from HttpErrorInterceptor) and the actual error was displayed above them.


picture.png

Reply all
Reply to author
Forward
0 new messages