[Library|Trunk]

Login guard: correct query params for redirectUrl

user compoents: fixes for the use of baselink (don't add it when already exists in the route), rename baseurl to route in components functions



git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59442 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2020-09-21 12:50:04 +00:00
parent ead41bab9a
commit ca54df782c
3 changed files with 10 additions and 10 deletions

View File

@ -19,11 +19,11 @@ export class LoginGuard implements CanActivate, CanLoad {
return user !== null;
}));
obs.pipe(filter(isLoggedIn => !isLoggedIn)).subscribe(() => {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, path}});
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN,'redirectUrl': path}});
});
return obs;
} else {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, path}});
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, 'redirectUrl':path}});
return false;
}
}

View File

@ -77,12 +77,12 @@ export class UserComponent {
redirect() {
if (this.redirectUrl && this.redirectUrl != "") {
this.redirectUrl = decodeURIComponent(this.redirectUrl);
var baseUrl = this.redirectUrl;
var route = this.redirectUrl;
var queryParams = "";
var paramsArray = [];
var valuesArray = [];
if (this.redirectUrl.indexOf('?') != -1) {
baseUrl = this.redirectUrl.split('?')[0];
route = this.redirectUrl.split('?')[0];
queryParams = this.redirectUrl.split('?')[1];
}
if (queryParams != "") {
@ -91,9 +91,9 @@ export class UserComponent {
paramsArray.push(queryParamsArray[i].split("=")[0]);
valuesArray.push(queryParamsArray[i].split("=")[1]);
}
this.router.navigate([baseUrl], {queryParams: this.routerHelper.createQueryParams(paramsArray, valuesArray)});
this.router.navigate([route], {queryParams: this.routerHelper.createQueryParams(paramsArray, valuesArray)});
} else {
this.router.navigate([baseUrl]);
this.router.navigate([route]);
}
}
// else{
@ -104,18 +104,18 @@ export class UserComponent {
logIn() {
if (this.redirectUrl && this.redirectUrl != "") {
this.redirectUrl = decodeURIComponent(this.redirectUrl);
var baseUrl = this.redirectUrl;
var route = this.redirectUrl;
var queryParams = "";
if (this.redirectUrl.indexOf('?') != -1) {
var splits = this.redirectUrl.split('?');
if (splits.length > 0) {
baseUrl = splits[0];
route = splits[0];
}
if (splits.length > 1) {
queryParams = splits[1];
}
}
Session.setReloadUrl(location.protocol + "//" + location.host,properties.baseLink + baseUrl, queryParams);
Session.setReloadUrl(location.protocol + "//" + location.host,properties.baseLink + route, queryParams);
}
console.log(Session.getReloadUrl());
window.location.href = this.properties.loginUrl;

View File

@ -239,7 +239,7 @@ export class UserMiniComponent implements OnInit, OnChanges {
}
logIn() {
Session.setReloadUrl(location.protocol + "//" + location.host, properties.baseLink + this.redirectUrl, this.search);
Session.setReloadUrl(location.protocol + "//" + location.host, this.redirectUrl, this.search);
window.location.href = this.logInUrl;
}