Refactor components. Improve design. Improve routing
This commit is contained in:
@@ -35,13 +35,18 @@ export default route(function (/* { store, ssrContext } */) {
|
||||
history: createHistory(process.env.VUE_ROUTER_BASE),
|
||||
});
|
||||
|
||||
Router.beforeEach(async (to, from, next) => {
|
||||
Router.beforeEach((to) => {
|
||||
const auth = useAuthStore();
|
||||
return !to.meta.accountRoute && !auth.currentUser
|
||||
? next({ name: 'login' })
|
||||
: to.meta.accountRoute && auth.currentUser
|
||||
? next({ name: 'index' })
|
||||
: next();
|
||||
|
||||
if (!auth.ready) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auth.currentUser) {
|
||||
return to.meta.accountRoute ? { name: 'index' } : true;
|
||||
} else {
|
||||
return to.name == 'login' ? true : { name: 'login' };
|
||||
}
|
||||
});
|
||||
|
||||
return Router;
|
||||
|
||||
Reference in New Issue
Block a user