title: How can I redirect a user if they are not authenticated using router
body: <p>In Angular 2 how can I redirect a user if they are not authenticated using router version 2.0.0-rc.1</p>
  
  <p>I'm looking to do this in my app.component where my routes are store.</p>
  
  <p>I want to detect if the user is authenticated before it hits a pages component.
  So I can then redirect them to the login.</p>
  
  <p>I've tried <strong>canActivate</strong> which doesnt seem to work for my router version.</p>
  
  <p>I'm looking for a solution for this version of the router:     <strong>"@angular/router": "2.0.0-rc.1"</strong></p>
  
  <p>OR</p>
  
  <p>A solution for the latest version of the router. If one is provided can you show me how to update my router version using git bash with this solution.</p>
  
  <p><strong>This is my current code:</strong></p>
  
  <pre><code>export class AppComponent implements CanActivate {
      authService: AuthService;
      userService: UserService;
  
      constructor(_authService: AuthService, _userService: UserService, private location: Location, private router: Router) {
          this.authService = _authService;
          this.userService = _userService;
      }
  
      canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable &lt; boolean &gt; | boolean {
  
          //This doesnt get hit
          console.log("here");
  
          return true;
      }
  }
  </code></pre>