Merge branch 'develop' into feature/api-admin-policies

This commit is contained in:
2025-12-29 14:53:44 +00:00
3 changed files with 34 additions and 9419 deletions
+21 -7
View File
@@ -16,10 +16,12 @@ const router = createRouter({
routes: [
{
path: '/',
name: 'home',
component: HomePage,
},
{
path: '/login',
name: 'login',
component: LoginPage,
},
{
@@ -36,6 +38,20 @@ const router = createRouter({
props: { gameType: 9 },
meta: { requiresAuth: true },
},
{
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: '/user',
component: UserPage,
@@ -73,15 +89,13 @@ const router = createRouter({
})
router.beforeEach((to, from, next) => {
if (to.meta.requiresAuth) {
const token = localStorage.getItem('token') // Ou useAuthStore().token
const requiresAuth = to.matched.some((record) => record.meta.requiresAuth)
if (requiresAuth) {
const token = localStorage.getItem('token')
if (!token) {
toast.error('Acesso Negado', {
description: 'Precisas de fazer login para aceder ao jogo.',
duration: 4000,
})
return next({ name: 'home' })
return next({ name: 'login' })
}
}
next()