Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

389
Views
How can I empty the Vue Store when redirected to login because the cookie expired?

The access cookie expires after 15 minutes and redirects the user to the login. But now I have to delete the cookie and empty the store as I did with the logout functionality.

I used js-cookie for handling cookies.

//router

router.beforeEach((to, from, next) => {
  const publicPages = ['/login', '/forgot-password', '/recover-password', 'email-forgot-password'];
  const authRequired = !publicPages.includes(to.path);
  const loggedIn = AuthService.getAccessToken();
  if (authRequired && !loggedIn) {
    next('/login');
  } else {
    next();
  }
});

//store

 setLogout(state) {
      state.user = {}
      state.company = {}
      state.wallet = null
      state.intWallet = []
      state.extWallet = []
      state.extWalletForWithdraw = []
      state.transactions = []
      state.movements = []
      state.token = null
      state.newTransaction = {
        fromWallet: null,
        toWallet: null,
        amount: 0,
      }
    }


  },

  actions: {
    logout(ctx) {
      //console.log(ctx)
      ctx.commit('setLogout')
      authService.deleteAccessToken()
      Company().deleteCompanyToken()
    }
  }

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!