[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:
parent
2b90952d2a
commit
8d82140ab9
|
@ -7,7 +7,6 @@ import {Router} from "@angular/router";
|
||||||
import {LoginErrorCodes} from "./login/utils/guardHelper.class";
|
import {LoginErrorCodes} from "./login/utils/guardHelper.class";
|
||||||
import {properties} from "../../environments/environment";
|
import {properties} from "../../environments/environment";
|
||||||
import {isArray} from "util";
|
import {isArray} from "util";
|
||||||
import {element} from "@angular/core/src/render3";
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ErrorInterceptorService implements HttpInterceptor {
|
export class ErrorInterceptorService implements HttpInterceptor {
|
||||||
|
@ -20,8 +19,10 @@ export class ErrorInterceptorService implements HttpInterceptor {
|
||||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
return next.handle(req).pipe(catchError(err => {
|
return next.handle(req).pipe(catchError(err => {
|
||||||
if ((err.status === 0 && this.isService(req, properties.registryUrl)) ||
|
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();
|
this.logOut();
|
||||||
|
} else if(err.status === 403) {
|
||||||
|
this.unauthorized();
|
||||||
}
|
}
|
||||||
return throwError(err);
|
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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="tm-header-mobile uk-hidden@m">
|
<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"
|
<div *ngIf="(properties.environment =='beta' || properties.environment =='development') && showLogo && header.badge"
|
||||||
class="uk-position-top-left">
|
class="uk-position-top-left">
|
||||||
<img class="small-beta-indication"
|
<img class="small-beta-indication"
|
||||||
|
|
Loading…
Reference in New Issue