X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fservices%2FAuthInterceptorService.ts;h=d2166e32fe60d25fb89e1e3a92c771002b38217d;hb=0a34dfa32165036b380ec6ac493469b34007df0a;hp=4a66482261af3d020c6343b645296e15a97d1f45;hpb=160b589f3d320fc1c24ef01705c842d919234897;p=osm%2FNG-UI.git diff --git a/src/services/AuthInterceptorService.ts b/src/services/AuthInterceptorService.ts index 4a66482..d2166e3 100644 --- a/src/services/AuthInterceptorService.ts +++ b/src/services/AuthInterceptorService.ts @@ -66,11 +66,11 @@ export class AuthInterceptorService implements HttpInterceptor { * @param next */ public intercept(req: HttpRequest<{}>, next: HttpHandler): Observable | HttpUserEvent | any> { const idToken: string = localStorage.getItem('id_token'); const excludedUrl: string[] = ['osm/admin/v1/tokens', 'assets/i18n/', 'osm/version']; - if (excludedUrl.some((x: string): boolean => { return req.url.includes(x); })) { return next.handle(req); } + if (excludedUrl.some((x: string): boolean => req.url.includes(x))) { return next.handle(req); } if (idToken.length > 0) { this.setHeader(req, idToken); return next.handle(this.clonedReq).pipe( @@ -85,7 +85,7 @@ export class AuthInterceptorService implements HttpInterceptor { } /** Set header options @public */ - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any public setHeader(req: HttpRequest, idToken: string): void { if (req.body !== null && req.body.byteLength !== null) { this.clonedReq = req.clone({ @@ -93,8 +93,12 @@ export class AuthInterceptorService implements HttpInterceptor { }); } else { this.clonedReq = req.clone({ - setHeaders: { Authorization: 'Bearer ' + idToken, 'Content-Type': 'charset=UTF-8', - 'Cache-Control': 'no-cache', Pragma: 'no-cache' } + setHeaders: { + Authorization: 'Bearer ' + idToken, + 'Content-Type': 'charset=UTF-8', + 'Cache-Control': 'no-cache', + Pragma: 'no-cache' + } }); } } @@ -119,7 +123,7 @@ export class AuthInterceptorService implements HttpInterceptor { /** Method to handle 401, 403 & 502 error */ private handleError(err: HttpErrorResponse): void { - if (err.error.detail !== 'Access denied: lack of permissions.') { + if (err.error.detail !== 'Access denied: lack of permissions.' && err.error.detail !== 'You cannot remove system_admin role from admin user') { this.notifierService.hideAll(); this.authService.logoutResponse(); if (this.authService.handle401) {