routing improved, settings initialized
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import store from '../store';
|
||||
import HomeView from '../views/HomeView.vue';
|
||||
import ActivateView from '../views/auth/ActivateView.vue';
|
||||
import PeronalSettingsView from '../views/settings/PersonalView.vue';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
@@ -12,9 +14,16 @@ const routes = [
|
||||
path: '/activate',
|
||||
name: 'Activate page',
|
||||
component: ActivateView
|
||||
},
|
||||
{
|
||||
path: '/settings/personal',
|
||||
name: 'Personal settings',
|
||||
component: PeronalSettingsView,
|
||||
meta: { requiresAuth: true }
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(process.env.BASE_URL),
|
||||
routes
|
||||
@@ -24,10 +33,10 @@ router.beforeEach((to, from, next) => {
|
||||
if (to.matched.some(record => record.meta.requiresAuth)) {
|
||||
if (!store.getters.isLoggedIn) {
|
||||
next('/');
|
||||
} else if (!store.user.active) {
|
||||
next();
|
||||
} else {
|
||||
} else if (!store.getters.user.active) {
|
||||
next('/activate');
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user