| Numéro du ticket | Titre du ticket | |------------------|-----------------| | #202 | Authentification — Connexion utilisateur (JWT) | ## Description de la PR [#202] Authentification — Connexion utilisateur (JWT) ## Modification du .env ## Check list - [x] Pas de régression - [ ] TU/TI/TF rédigée - [x] TU/TI/TF OK - [x] CHANGELOG modifié Reviewed-on: #5 Reviewed-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr> Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
18 lines
317 B
TypeScript
18 lines
317 B
TypeScript
import { useAuthStore } from '~/stores/auth'
|
|
|
|
export default defineNuxtRouteMiddleware(async (to) => {
|
|
const auth = useAuthStore()
|
|
|
|
if (to.path === '/login') {
|
|
return
|
|
}
|
|
|
|
if (!auth.isAuthenticated) {
|
|
await auth.ensureSession()
|
|
}
|
|
|
|
if (!auth.isAuthenticated) {
|
|
return navigateTo('/login')
|
|
}
|
|
})
|