Version 1.0 #102
Generated
-9409
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,19 @@
|
||||
### Get All Students
|
||||
### Get All Students (Login)
|
||||
# @name login
|
||||
POST http://localhost:8000/api/login
|
||||
content-Type: application/json
|
||||
Content-Type: application/json
|
||||
Accept: application/json
|
||||
|
||||
{
|
||||
"email": "[email protected]",
|
||||
"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}}
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user