condition on Angular routing

firstly, if first user already login in first tab and it will redirect to dashboard, when first user open second tab in same browser(paste login Url), automatically it will redirect to dashboard without going to login page.I had condition where in the login page there are specific routes that unauthenticated user can access,


linkToMarket(): void { 
this.sidenav.close().then(() => {

on Market page (in second tab),user can return back to login page, but unfortunately it will redirect through dashboard (because first user already logged in) as I implemented this redirect to dashboard if user is logged in, how can I make sure if there are differrent user on second tab, when return from market page, it will not redirect to dashboard but login page, whether I can make condition on route or use Authguard(CanActivate) ?

detail.login component

ngOnInit(): void {
    if (this.authenService.isUserAuthenticated()) {


 linkToSignIn(): void {
    this.router.navigate([UrlConstants.Login], { queryParams: { returnUrl: UrlConstants.Market } });
    if (this.authenService.isUserAuthenticated()) {

Source: Angular

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.