title: Checks in vue-router.beforeEach not restricting access to routes
body: <p>First off, I'm using vuejs 2.0 with webpack, vue-router (in history mode - SPA site), and vuex running on the webpack dev server with hot module loading.</p>
  
  <p>I have about 10 routes mapped out to components.  Site is working great, but now I'm adding some token based authentication. I'm using router.beforeEach to perform a token check.  If the token is valid, it should let them through.  If the token is NOT valid, it should redirect them to the <em>/login</em> page.  The problem is that it performs the check and restricts it the first time.  But the second attempt allows me to go to the page and display the contents.  Every second request seems to process the route properly and redirect to <em>/login</em>.  My checkToken() function is always returning false, for testing purposes.</p>
  
  <p>Code:</p>
  
  <pre><code>// Configure Router
  const router = new Router({
      routes, //routes are configured elsewhere, they work fine so not needed
      mode: 'history'
  })
  
  router.beforeEach((to, from, next) =&gt; {
      if(to.path != '/login') {
          if(checkToken()) { 
              logger('There is a token, resume. (' + to.path + ')');
              next();
          } else {
              logger('There is no token, redirect to login. (' + to.path + ')');
              next('login');
              // next('/login');
              // router.push('login');
          }
      } else {
          logger('You\'re on the login page');
      }
      next();
  });
  
  
  function checkToken() {
      return false;
  }
  </code></pre>
  
  <p>Going to the main page ("/"), it redirects to <em>/login</em> as expected.  In my console, I have the following 2 entries:</p>
  
  <blockquote>
    <p>[ 14:36:30.399 ] : There is no token, redirect to login. (/) 
    [ 14:36:30.399 ] : You're on the login page</p>
  </blockquote>
  
  <p>Seems to be good.  It tried to load "/" and saw there was no token, then redirected to <em>/login</em> where the check sees that we're on the login page and stops.</p>
  
  <p>Now I'll click on my <em>Projects</em> link that will take me to <em>/project</em>.  Console output:</p>
  
  <blockquote>
    <p>[ 14:40:21.322 ] : There is no token, redirect to login. (/project)</p>
  </blockquote>
  
  <p>Perfect, but the <em>projects</em> page is actually being displayed rather than the <em>login</em> page.</p>
  
  <p>Now I'll click on my <em>Sites</em> link that should take me to <em>/site</em>.  Console output:</p>
  
  <blockquote>
    <p>[ 14:41:50.790 ] : There is no token, redirect to login. (/site) [
    14:41:50.792 ] : You're on the login page</p>
  </blockquote>
  
  <p>Looks good, AND the browser is displaying the <em>site</em> page.  This is exactly what I want to see.</p>
  
  <p>Now I'll click on my <em>Requests</em> link that to <em>/request</em>.  Console output:</p>
  
  <blockquote>
    <p>[ 14:44:13.114 ] : There is no token, redirect to login. (/request)</p>
  </blockquote>
  
  <p>but once again, it's not redirecting.  I'm seeing my <em>request</em> page when I should be seeing my <em>login</em> page.</p>
  
  <p>This time, I'll click on my <em>Projects</em> link again (<em>/project</em>) that incorrectly displayed the <em>project</em> page rather than the <em>login</em> page.  Console output:</p>
  
  <blockquote>
    <p>[ 14:47:12.799 ] : There is no token, redirect to login. (/project) [
    14:47:12.800 ] : You're on the login page</p>
  </blockquote>
  
  <p>This time, it redirected my to the <em>/login</em> page, as it should.</p>
  
  <p>It is literally every other link I click that gets redirected appropriately, no matter what order or which link I click.  First one redirects, second one doesn't, third one does, fourth doesn't, fifth does, etc...</p>
  
  <p>I've tried next('/login'), next('login'), and router.push('login') and they're all the same result.  It knows when it's supposed to redirect, but the redirect only works every other time.</p>
  
  <p>If I do a full request (page refresh, type the address in and press enter), it will always redirect to <em>/login</em> as planned, but I'm trying to do this with an SPA.  Anything I'm missing?</p>