mirror of
https://github.com/Dannecron/ich-lerne-deutsch.git
synced 2025-12-25 21:02:35 +03:00
add auth middleware, add page not found processing
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
import Vue from 'vue';
|
||||
import Router from 'vue-router';
|
||||
import Store from '@/store';
|
||||
import NotFound from '@/views/Errors/NotFound';
|
||||
import Home from '@/views/Home';
|
||||
|
||||
Vue.use(Router);
|
||||
|
||||
function AuthMiddleware(from, to, next) {
|
||||
if (Store.getters.isUserAuthentificated) {
|
||||
next();
|
||||
} else {
|
||||
next('/sign_in');
|
||||
}
|
||||
}
|
||||
|
||||
export default new Router({
|
||||
routes: [
|
||||
{
|
||||
@@ -25,6 +35,7 @@ export default new Router({
|
||||
path: '/profile',
|
||||
name: 'profile',
|
||||
component: () => import(/* webpackChunkName: "words" */ '@/views/Profile.vue'),
|
||||
beforeEnter: AuthMiddleware,
|
||||
},
|
||||
{
|
||||
path: '/sign_in',
|
||||
@@ -36,6 +47,10 @@ export default new Router({
|
||||
name: 'signUp',
|
||||
component: () => import(/* webpackChunkName: "sign_up" */ '@/views/SignUp.vue'),
|
||||
},
|
||||
{
|
||||
path: '*',
|
||||
component: NotFound,
|
||||
}
|
||||
],
|
||||
mode: 'history',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user