I am working on creating specific routes for different users to ensure each user has a tailored experience. For example, if a user is logged in as an admin, they should be directed to '/admin'
instead of '/home'
.
Here's what I've done so far.
index.js - routes file
{
path: '/',
name: 'Home',
component: Home,
meta: {
requiresAuth: true,
user:'normal-user'
},
beforeEnter: (to, from, next) => {
console.log(from)
if(from.path == '/admin' || from.path == '/forms' || from.path == '/steps') {
next('/admin')
}
else
next()
}
}
Remember that there are also routes for /forms
and /steps
.
My goal is to redirect the user back to '/admin'
if they try to access '/' after coming from the '/admin'
route.
I have implemented this functionality, but I'm open to suggestions on how to improve it. Any recommendations?