title: Vue/Vuex - how to stay logged in as a user after route change
body: <p>As a small Dev-Team, we are about to create our own social media website just for fun.</p>
  <p>Our login process is handled with a jwt which is stored in localStorage.</p>
  <pre class="lang-js prettyprint-override"><code>  async login( { commit }, user) {
      commit('auth_request');
  
      try {
        const res = await axios.post('http://localhost:3000/api/v1/users/login', user);
        if (res.data.status === 'success') {
          const token = res.data.token;
          const user = res.data.user;
          localStorage.setItem('jwt', token);
          commit('auth_success', { token, user }  );
          toast.success(res.data.message);
          router.push({ path: '/' })
        }
        return res;
      } catch (error) {
        commit('set_errors', error.response.data)
        toast.error(error.response.data.message);
      }
    },
  </code></pre>
  <p>However as soon as we change route we getting logged out.<br />
  <a href="https://i.stack.imgur.com/tFsBL.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tFsBL.gif" alt="preview of our issue" /></a></p>
  <pre class="lang-js prettyprint-override"><code>router.beforeEach((to, from, next) =&gt; {
    // check for user is logged in on route change
    next();
  })
  </code></pre>
  <p>How to prevent getting logged out on route change or page reload?</p>