Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
routes.beforeEach((to, from, next) => {
let token = Cookies('username');
if (!to.name) {
next({
name: 'list'
});
} else if (to.name == 'login') {
if (!token || !store.state.auth.username) {
next();
} else {
next({
name: 'list'
});
}
} else if (to.params.status == 2 || (to.matched.some(record => record.meta.requiresAuth) && (!token || token === null))) {
next({
path: '/login'
});