Merge remote-tracking branch 'origin/develop' into stats-profile

This commit is contained in:
Konstantinos Triantafyllou 2023-06-30 14:40:06 +03:00
commit 94957fff61
2 changed files with 13 additions and 5 deletions

View File

@ -3,15 +3,25 @@ import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from "@angular/com
import {Observable, throwError, TimeoutError} from "rxjs";
import {catchError} from "rxjs/operators";
import {Session} from "./login/utils/helper.class";
import {Router} from "@angular/router";
import {GuardsCheckEnd, GuardsCheckStart, Router} from "@angular/router";
import {LoginErrorCodes} from "./login/utils/guardHelper.class";
import {properties} from "../../environments/environment";
import * as url from "url";
@Injectable()
export class ErrorInterceptorService implements HttpInterceptor {
private static UNAUTHORIZED_WHITELIST = [properties.userInfoUrl, properties.orcidAPIURL, properties.registryUrl? (properties.registryUrl + 'verification/'):null, properties.eoscDataTransferAPI].filter(value => !!value);
private url: string = null;
constructor(private router: Router) {
this.router.events.forEach(event => {
if(event instanceof GuardsCheckStart) {
this.url = event.url;
} else if(event instanceof GuardsCheckEnd) {
this.url = null;
}
})
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
@ -42,7 +52,7 @@ export class ErrorInterceptorService implements HttpInterceptor {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_LOGIN,
'redirectUrl': this.router.url
'redirectUrl': this.url?this.url:this.router.url
}
});
}
@ -51,7 +61,7 @@ export class ErrorInterceptorService implements HttpInterceptor {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_AUTHORIZED,
'redirectUrl': this.router.url
'redirectUrl': this.url?this.url:this.router.url
}
});
}

View File

@ -16,7 +16,6 @@ export class ReloadComponent {
public ngOnInit() {
let URL = Session.getReloadUrl();
console.log(URL);
if (URL && URL["path"] && URL["path"] != "") {
let url: string = URL["path"];
let host = URL["host"];
@ -24,7 +23,6 @@ export class ReloadComponent {
if (host == (location.protocol + "//" + location.host)) {
let baseUrl = (document && document.getElementsByTagName('base')) ? document.getElementsByTagName('base')[0].href.split(document.location.host)[1] : "/";
url = (baseUrl.length > 1 && url.indexOf(baseUrl) != -1) ? ("/" + url.split(baseUrl)[1]) : url;
console.log(url);
if (paramsObject) {
Session.setReloadUrl("", "", "", "");
if(URL['fragment'] && URL['fragment'] !== '') {