We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 177cd51 commit 5b1b311Copy full SHA for 5b1b311
auth/src/router.js
@@ -0,0 +1,38 @@
1
+import Vue from 'vue';
2
+import VueRouter from 'vue-router';
3
+
4
+import store from './store';
5
6
+import IndexPage from './pages/Index';
7
+import LoginPage from './pages/Login';
8
9
+const router = new VueRouter({
10
+ mode: 'history',
11
+ routes: [
12
+ {
13
+ path: '/',
14
+ name: 'index',
15
+ component: IndexPage,
16
+ },
17
18
+ path: '/login',
19
+ name: 'login',
20
+ component: LoginPage,
21
22
+ ]
23
+});
24
25
+/**
26
+ * Navigation Guards
27
+ * Redirect to login if the user is not authenticated
28
+ */
29
+router.beforeEach((to, from, next) => {
30
+ if (to.name !== 'login' && !store.state.accessToken) {
31
+ next('/login');
32
+ }
33
+ next();
34
35
36
+Vue.use(VueRouter);
37
38
+export default router;
0 commit comments