Fix login bug. Improve reservations

This commit is contained in:
2024-05-21 16:32:31 -04:00
parent 737de91bbc
commit cd692a6f3b
10 changed files with 103 additions and 81 deletions

View File

@@ -36,12 +36,13 @@ export default route(function (/* { store, ssrContext } */) {
});
Router.beforeEach((to) => {
const auth = useAuthStore();
const publicPages = routes
.filter((route) => route.meta?.publicRoute)
.map((r) => r.path);
const authRequired = !publicPages.includes(to.path);
if (auth.currentUser) {
return to.meta.accountRoute ? { name: 'index' } : true;
} else {
return to.name == 'login' ? true : { name: 'login' };
if (authRequired && !useAuthStore().currentUser) {
return '/login';
}
});