title: Angular2 Redirect After Login
body: <p>I'm creating an authentication system in angular2 with the idea that if a user that is not authenticated tries to navigated to a "protected" url, the system will redirect the user to the login page putting in the url a query param called "next" that will help the login system redirect the user back to where he wanted to be in the first place.</p>
  
  <p><code>login?next=my-redirect-url</code></p>
  
  <p>To protect my components, I'm using the decorator <code>@CanActivate(isUserAuthenticated)</code> in all of them. The <code>isUserAuthenticated</code> function is something as follows:</p>
  
  <pre class="lang-js prettyprint-override"><code>function isUserAuthenticated(
      prevInstr: ComponentInstruction, 
      nextInstr: ComponentInstruction
  ): boolean {
      const authService = injector.get(AuthService);
      const router = injector.get(Router);
      if(authService.isLoggedIn()) {
          return true;
      } else {
          router.navigate(["/Login", {next: nextInstr.urlPath}]);
          return false;
      }
  }
  </code></pre>
  
  <p>This approach is not working because the <code>urlPath</code> property of the <code>nextInstr</code> is not showing the "complete" url (it lacks query params for example).</p>
  
  <p>Is there a way to build the complete url from a <code>ComponentInstruction</code> instance like <code>nextInstr</code>?</p>