From 4b311c74ebe38a65976996d08801ec5663581119 Mon Sep 17 00:00:00 2001 From: FernandoJVideira <03.pleaser-minster@icloud.com> Date: Mon, 29 Dec 2025 14:47:32 +0000 Subject: [PATCH] fix: added missing route --- frontend/src/router/index.js | 38 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 165ddc6..86fc02b 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -6,41 +6,21 @@ import TestAnimations from '@/pages/TestAnimations.vue' import TestDealing from '@/pages/TestDealing.vue' import TestAllAnimations from '@/pages/TestAllAnimations.vue' import TestGameBoard from '@/pages/TestGameBoard.vue' +import UserPage from '@/pages/user/UserPage.vue' import SinglePlayerGamePage from '@/pages/game/SinglePlayerGamePage.vue' import { createRouter, createWebHistory } from 'vue-router' import { toast } from 'vue-sonner' -import TestAnimations from '@/pages/TestAnimations.vue' -import TestDealing from '@/pages/TestDealing.vue' -import TestAllAnimations from '@/pages/TestAllAnimations.vue' -import TestGameBoard from '@/pages/TestGameBoard.vue' -import SinglePlayerGamePage from '@/pages/game/SinglePlayerGamePage.vue' const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes: [ { path: '/', - name: 'home', component: HomePage, }, { path: '/login', - name: 'login', component: LoginPage, - }, - { - path: '/game/3', - name: 'bisca3', - component: SinglePlayerGamePage, - props: { gameType: 3 }, - meta: { requiresAuth: true }, - }, - { - path: '/game/9', - name: 'bisca9', - component: SinglePlayerGamePage, - props: { gameType: 9 }, - meta: { requiresAuth: true }, }, { path: '/game/3', @@ -56,6 +36,10 @@ const router = createRouter({ props: { gameType: 9 }, meta: { requiresAuth: true }, }, + { + path: '/user', + component: UserPage, + }, { path: '/testing', children: [ @@ -89,13 +73,15 @@ const router = createRouter({ }) router.beforeEach((to, from, next) => { - const requiresAuth = to.matched.some((record) => record.meta.requiresAuth) - - if (requiresAuth) { - const token = localStorage.getItem('token') + if (to.meta.requiresAuth) { + const token = localStorage.getItem('token') // Ou useAuthStore().token if (!token) { - return next({ name: 'login' }) + toast.error('Acesso Negado', { + description: 'Precisas de fazer login para aceder ao jogo.', + duration: 4000, + }) + return next({ name: 'home' }) } } next()