Override the redirectTo with the loginFragment (#6239)

* Override the redirectTo with the loginFragment

* Add check
This commit is contained in:
Maurizio Vitale 2020-10-12 23:40:25 +01:00 committed by GitHub
parent f852811920
commit 01fb4fa2b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,7 +65,10 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
if (this.authenticationService.isEcmLoggedIn() || this.withCredentials) {
if (redirectFragment) {
this.storageService.removeItem('loginFragment');
return this.router.createUrlTree([redirectFragment]);
const routeRedirectTo = route.routeConfig.children.filter( (routeTo) => routeTo.path === '' );
if (routeRedirectTo?.length > 0) {
routeRedirectTo[0].redirectTo = redirectFragment;
}
}
return true;
}