Angular2: Prevent authenticated users from accessing specific routes
<p>I've defined some <code>routes</code> in my <code>main.ts</code> file:</p>

<pre><code>const routes: RouterConfig = [
  { path: '', component: HomeComponent },
  { path: '', redirectTo: 'home', terminal: true },
  { path: 'dashboard', component: DashboardComponent, canActivate: [LoggedInGuard] },
  { path: 'login', component: LoginComponent },
  { path: 'about', component: AboutComponent } 
];
</code></pre>

<p>After successful login I want my authenticated users can be able to use specific routes (e.g. <code>dashboard</code>). And without login they cannot access <code>dashboard</code> but they can be able to visit <strong>about,home,login</strong></p>

<p>I've managed to restrict users traversing the <code>dashboard</code> without login, using <code>CanActivate</code>.</p>

<pre><code>canActivate(): boolean {
    if (this.authService.isLoggedIn()) {
      return true; 
    }
    this.router.navigateByUrl('/login');
    return false;
  }
</code></pre>

<p>But Using those routes and the <code>CanActivate</code> approach after successful login, users are also able to goto routes like <code>login</code>, <code>home</code>. How can I prevent that? </p>

<p>N.B. I'm using angular2 RC4. </p>