Many fix and improvements
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useUserStore } from "@/stores/user.js";
|
||||
import GuillaumeAime from '@/views/manualusers/GuillaumeAime.vue'
|
||||
import About from '@/views/documentation/About.vue'
|
||||
import ContentPolicy from '@/views/documentation/ContentPolicy.vue'
|
||||
@@ -22,6 +21,7 @@ import CreatorList from '../views/creators/CreatorList.vue'
|
||||
import CreatorPage from "@/views/creators/CreatorPage.vue";
|
||||
import ContentPage from "@/views/contents/ContentPage.vue";
|
||||
import PostContent from "@/views/contents/PostContent.vue";
|
||||
import {useAuthStore} from "@/stores/authStore.js";
|
||||
|
||||
const routes = [
|
||||
{
|
||||
@@ -114,18 +114,6 @@ const routes = [
|
||||
component: Join,
|
||||
meta: { hideSideBar: true }
|
||||
},
|
||||
|
||||
{
|
||||
path: '/paymentcompleted',
|
||||
name: 'PayementCompleted',
|
||||
component: PaymentCompleted
|
||||
},
|
||||
{
|
||||
path: '/profile',
|
||||
name: 'profile',
|
||||
component: Profile,
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/signup',
|
||||
name: 'signup',
|
||||
@@ -136,12 +124,23 @@ const routes = [
|
||||
name: 'login',
|
||||
component: LoginView
|
||||
},
|
||||
{
|
||||
path: '/paymentcompleted',
|
||||
name: 'PayementCompleted',
|
||||
component: PaymentCompleted,
|
||||
},
|
||||
{
|
||||
path: '/wallet',
|
||||
name: 'wallet',
|
||||
component: Wallet,
|
||||
meta: { requiresAuth: true }
|
||||
}
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/profile',
|
||||
name: 'profile',
|
||||
component: Profile,
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
@@ -151,11 +150,10 @@ const router = createRouter({
|
||||
|
||||
// Navigation gards
|
||||
router.beforeEach((to, from, next) => {
|
||||
const authStore = useUserStore();
|
||||
const authStore = useAuthStore();
|
||||
|
||||
|
||||
if (to.matched.some(record => record.meta.requiresAuth)) {
|
||||
if (!authStore.user.value || !Object.keys(authStore.user.value).length) {
|
||||
if (!authStore.isAuthenticated) {
|
||||
next('/');
|
||||
} else {
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user