Version 1.0 #102

Merged
FernandoJVideira merged 163 commits from develop into master 2026-01-03 14:49:00 +00:00
3 changed files with 34 additions and 9419 deletions
Showing only changes of commit 51f745a3dd - Show all commits
-9409
View File
File diff suppressed because it is too large Load Diff
+12 -2
View File
@@ -1,9 +1,19 @@
### Get All Students ### Get All Students (Login)
# @name login
POST http://localhost:8000/api/login POST http://localhost:8000/api/login
content-Type: application/json Content-Type: application/json
Accept: application/json Accept: application/json
{ {
"email": "[email protected]", "email": "[email protected]",
"password": "123" "password": "123"
} }
### Capture the token
@token = {{login.response.body.token}}
### Get All matches
GET http://localhost:8000/api/matches
Content-Type: application/json
Accept: application/json
Authorization: Bearer {{token}}
+21 -7
View File
@@ -16,10 +16,12 @@ const router = createRouter({
routes: [ routes: [
{ {
path: '/', path: '/',
name: 'home',
component: HomePage, component: HomePage,
}, },
{ {
path: '/login', path: '/login',
name: 'login',
component: LoginPage, component: LoginPage,
}, },
{ {
@@ -36,6 +38,20 @@ const router = createRouter({
props: { gameType: 9 }, props: { gameType: 9 },
meta: { requiresAuth: true }, 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', path: '/user',
component: UserPage, component: UserPage,
@@ -73,15 +89,13 @@ const router = createRouter({
}) })
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
if (to.meta.requiresAuth) { const requiresAuth = to.matched.some((record) => record.meta.requiresAuth)
const token = localStorage.getItem('token') // Ou useAuthStore().token
if (requiresAuth) {
const token = localStorage.getItem('token')
if (!token) { if (!token) {
toast.error('Acesso Negado', { return next({ name: 'login' })
description: 'Precisas de fazer login para aceder ao jogo.',
duration: 4000,
})
return next({ name: 'home' })
} }
} }
next() next()