Skip to content

Commit

Permalink
Merge pull request #97 from Azordev/fix/#96
Browse files Browse the repository at this point in the history
Added guard in login to avoid logged users enter
  • Loading branch information
heliomar-pena authored Sep 16, 2022
2 parents 192c45f + 1ceef90 commit 46faa8d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export default route(function (/* { store, ssrContext } */) {
Router.beforeEach((to) => {
const user = LocalStorage.getItem('user') as User;

if (user && to.name === 'login') {
return { name: 'dashboard' };
}

if (to.meta.requiresAuth && !user) {
return { name: 'login', query: { to: to.path } };
}
Expand Down

0 comments on commit 46faa8d

Please sign in to comment.