I have multi auth application in vuejs . So, in router.js i checked that if customer is logged in it should redirect to customer dashboard and if admin is logged in it should redirect to admin dashboard
In router.js I have implemented it in beforeEach() . But it is redirecting it many time which gives error.
here is my router.js beforeEachFunction()
if (Object.keys(store.state.AppActiveUser).length !== 0 && !store.state.AppActiveUser.is_customer ) {
if (!to.meta.authRequired && auth.isAuthenticated()) {
router.push({ path: '/dashboard', name: 'dashboard', component: './views/DashboardAnalytics.vue' })
}
} if (Object.keys(store.state.AppActiveUser).length !== 0 && store.state.AppActiveUser.is_customer) {
if (!to.meta.authRequired && auth.isAuthenticated()) {
router.push({ path: '/customer/dashboard', name: 'customer-dashboard', component: '@/views/apps/customerComponents/dashboard/DashboardAnalytics.vue' })
}
}
Here is the error
Uncaught (in promise) RangeError: Maximum call stack size exceeded
at iterator (app.js:51760)
at step (app.js:51410)
at app.js:51411
at app.js:51785
at app.js:98591
at iterator (app.js:51763)
at step (app.js:51410)
at runQueue (app.js:51418)
at HTML5History.confirmTransition (app.js:51793)
at HTML5History.transitionTo (app.js:51666)
Actuallly before coming to beforeEach i pushe routes in router depend in customer or admin .
Now when I goto customer route it is not having /dashboard route so it tryies again and again I think