[Library | Trunk]: Fix error interceptor to logout only in 401. Fix navbar on mobiles to be transparent

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59967 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2020-11-25 17:32:20 +00:00
parent 2b90952d2a
commit 8d82140ab9
2 changed files with 13 additions and 3 deletions

View File

@ -7,7 +7,6 @@ import {Router} from "@angular/router";
import {LoginErrorCodes} from "./login/utils/guardHelper.class";
import {properties} from "../../environments/environment";
import {isArray} from "util";
import {element} from "@angular/core/src/render3";
@Injectable()
export class ErrorInterceptorService implements HttpInterceptor {
@ -20,8 +19,10 @@ export class ErrorInterceptorService implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req).pipe(catchError(err => {
if ((err.status === 0 && this.isService(req, properties.registryUrl)) ||
(err.status === 401 && !this.isService(req, ErrorInterceptorService.UNAUTHORIZED_WHITELIST)) || err.status === 403) {
(err.status === 401 && !this.isService(req, ErrorInterceptorService.UNAUTHORIZED_WHITELIST))) {
this.logOut();
} else if(err.status === 403) {
this.unauthorized();
}
return throwError(err);
}));
@ -44,4 +45,13 @@ export class ErrorInterceptorService implements HttpInterceptor {
}
});
}
unauthorized() {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_AUTHORIZED,
'redirectUrl': this.router.url
}
});
}
}

View File

@ -7,7 +7,7 @@
</a>
</div>
<div class="tm-header-mobile uk-hidden@m">
<nav class="uk-navbar-container uk-navbar" uk-navbar="">
<nav class="uk-navbar-container uk-navbar" uk-navbar="" [class.uk-navbar-transparent]="header.stickyAnimation === false">
<div *ngIf="(properties.environment =='beta' || properties.environment =='development') && showLogo && header.badge"
class="uk-position-top-left">
<img class="small-beta-indication"