BUG 1221:Reset of NG-UI service leaves unusable UI 69/9769/1 v8.0.2
authorBarath Kumar R <barath.r@tataelxsi.co.in>
Thu, 1 Oct 2020 09:17:24 +0000 (14:47 +0530)
committerBarath Kumar R <barath.r@tataelxsi.co.in>
Thu, 1 Oct 2020 09:17:24 +0000 (14:47 +0530)
 * Fixed the issue, Called the logout function in the 401 unauthorized

Change-Id: I8a2ababc8010df664d9b401ce0bda2ae38f5668b
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
src/services/AuthInterceptorService.ts

index ede10a8..4a66482 100644 (file)
@@ -103,18 +103,23 @@ export class AuthInterceptorService implements HttpInterceptor {
     public errorRes(err: HttpErrorResponse, req: HttpRequest<{}>, next: HttpHandler): Observable<{}> {
         if (err instanceof HttpErrorResponse) {
             switch (err.status) {
-                case HttpStatus.UNAUTHORIZED || HttpStatus.FORBIDDEN:
+                case HttpStatus.UNAUTHORIZED:
+                case HttpStatus.FORBIDDEN:
                     this.handleError(err);
                     break;
+                case HttpStatus.GATEWAY_TIMEOUT:
+                case HttpStatus.BAD_GATEWAY:
+                    this.notifierService.hideAll();
+                    this.authService.logoutResponse();
+                    break;
                 default: return throwError(err);
             }
         } else { return throwError(err); }
     }
 
-    /** Method to handle  401 & 403 error */
+    /** Method to handle  401, 403 & 502 error */
     private handleError(err: HttpErrorResponse): void {
-        if (err.error.detail === 'Expired Token or Authorization HTTP header' ||
-            err.error.detail === 'Invalid Token or Authorization HTTP header') {
+        if (err.error.detail !== 'Access denied: lack of permissions.') {
             this.notifierService.hideAll();
             this.authService.logoutResponse();
             if (this.authService.handle401) {