Skip to content

Commit

Permalink
Simplify authGuard statements
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraluiz committed Aug 29, 2018
1 parent ee46c49 commit ddd04e1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ const router = new Router({
});

const authGuard = (to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth)) {
if (store.getters.isAuthenticated) {
next();
} else {
next({ name: 'login' });
}
const routeRequiresAuth = to.matched.some(record => record.meta.requiresAuth);
if (routeRequiresAuth && !store.getters.isAuthenticated) {
next({ name: 'login' });
} else {
next();
}
Expand Down

0 comments on commit ddd04e1

Please sign in to comment.