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',
|
||||
});
|
||||
|
||||
22
src/views/Errors/NotFound.vue
Normal file
22
src/views/Errors/NotFound.vue
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<v-alert
|
||||
:value="true"
|
||||
color="error"
|
||||
icon="warning"
|
||||
outline
|
||||
>
|
||||
Страница, которую вы запросили, не существует.
|
||||
</v-alert>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'notFound',
|
||||
components: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user