feature/api-admin-policies #78
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
|
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}}
|
||||||
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user