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

122
Views
El enrutador no responde a los cambios de estado. vista

Enrutador: verifique la autenticación antes de renderizar

 router.beforeEach((to, from, next) => { const requireAuth = to.meta.auth if (requireAuth && store.getters['auth/isAuthenticated']) { next() } else if (requireAuth && !store.getters['auth/isAuthenticated']) { next({name: 'login'}) } else if (!requireAuth && store.getters['auth/isAuthenticated']) { next({name: 'admin'}) } else { next() } })

Vuex:

 state() { return { isAuth: false, user: null, emailFormFactor: '' } }, getters: { isAuthenticated(state) { return state.isAuth }, getEmailFormFactor(state) { return state.emailFormFactor }, getUser(state) { return state.user } }

aplicación

 onBeforeMount( () => { if (localStorage.getItem('auth-token')) { store.dispatch('auth/checkAuth') } } )

Antes tengo que comprobar la validez del token y después si hay cambio de estado. ¿Es necesario rastrearlo en el enrutador? Gracias

about 4 years ago · Juan Pablo Isaza
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!