control back button

This commit is contained in:
_Bastler 2021-09-08 11:09:26 +02:00
parent 258f253a14
commit 885c95e63b
3 changed files with 49 additions and 49 deletions

View File

@ -29,7 +29,7 @@ export class AuthGuard implements CanActivate {
return this.authService.getAuth().then(response => {
return true;
}).catch(function (error) {
return that.router.parseUrl('/unavailable?target=' + state.url);
return that.router.navigateByUrl(that.router.parseUrl('/unavailable?target=' + next.url), { skipLocationChange: true });
});
}
}
@ -44,7 +44,7 @@ export class AuthenticatedGuard implements CanActivate {
const that = this;
return this.authService.getAuth().then((data: any) => {
if (!data.authenticated) {
return that.router.parseUrl('/login?target=' + state.url);
return that.router.navigateByUrl(that.router.parseUrl('/login?target=' + state.url), { skipLocationChange: true, replaceUrl: true });
}
this.profileService.get([ "locale", "darkTheme" ]).subscribe((profileFields: any) => {
@ -74,7 +74,7 @@ export class AuthenticatedGuard implements CanActivate {
return true;
}).catch(function (error) {
return that.router.parseUrl('/unavailable?target=' + state.url);
return that.router.navigateByUrl(that.router.parseUrl('/unavailable?target=' + next.url), { skipLocationChange: true });
});
}
}
@ -94,7 +94,7 @@ export class AnonymousGuard implements CanActivate {
}
return true;
}).catch(function (error) {
return that.router.parseUrl('/unavailable?target=' + state.url);
return that.router.navigateByUrl(that.router.parseUrl('/unavailable?target=' + next.url), { replaceUrl: true });
});
}

View File

@ -23,11 +23,11 @@ export class FormLoginComponent implements OnInit {
this.route.queryParams.subscribe(params => {
if (params[ 'target' ]) {
this.targetRoute = params[ 'target' ];
this.router.navigate([], {queryParams: {target: null}, queryParamsHandling: 'merge'});
this.router.navigate([], { queryParams: { target: null }, queryParamsHandling: 'merge', replaceUrl: true });
}
if (params[ 'error' ] || params[ 'error' ] == '') {
this.loginInvalid = true;
this.router.navigate([], {queryParams: {error: null}, queryParamsHandling: 'merge'});
this.router.navigate([], { queryParams: { error: null }, queryParamsHandling: 'merge', replaceUrl: true });
}
});

View File

@ -19,7 +19,7 @@ export class UnavailableComponent implements OnInit {
this.route.queryParams.subscribe(params => {
if (params[ 'target' ]) {
this.targetRoute = params[ 'target' ];
this.router.navigate([], {queryParams: {target: null}, queryParamsHandling: 'merge'});
this.router.navigate([], { queryParams: { target: null }, queryParamsHandling: 'merge', skipLocationChange: true });
}
});
@ -29,7 +29,7 @@ export class UnavailableComponent implements OnInit {
if (!this.targetRoute || this.targetRoute === "unavailable" || this.targetRoute === "/unavailable") {
this.location.back;
} else {
this.router.navigate([this.targetRoute]);
this.router.navigate([ this.targetRoute ], { skipLocationChange: true });
}
}