Skip to content

Commit

Permalink
fix: 🐛 fix endless redirect on login if authenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
clairenollet committed Nov 10, 2023
1 parent 36235c1 commit 8ee024b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/client/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ router.beforeEach(async (to, _from, next) => {
return next('Login')
}

// Redirige sur l'accueil si le path est Login et que l'utilisateur est connecté
if (to.name === 'Login' && userStore.isLoggedIn) {
return next('/')
}

// Redirige sur la page d'accueil si le path est admin et l'utilisateur n'est pas admin
if (to.path.match('^/admin/') && !userStore.isAdmin) {
snackbarStore.setMessage('Vous ne possédez pas les droits administeurs', 'error')
Expand Down

0 comments on commit 8ee024b

Please sign in to comment.