Skip to content
Snippets Groups Projects
Commit 72188822 authored by VIktorGrev's avatar VIktorGrev
Browse files

feat: Adding iAuth in routing

parent 87bf31fe
No related branches found
No related tags found
No related merge requests found
Pipeline #274961 failed
...@@ -18,7 +18,6 @@ function toRoadmap(){ ...@@ -18,7 +18,6 @@ function toRoadmap(){
</script> </script>
<template> <template>
<Menu></Menu>
<div class="container text-center"> <div class="container text-center">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
...@@ -120,7 +119,6 @@ function toRoadmap(){ ...@@ -120,7 +119,6 @@ function toRoadmap(){
</div> </div>
</div> </div>
</div> </div>
<Footer></Footer>
</template> </template>
<style scoped> <style scoped>
......
...@@ -17,10 +17,9 @@ const routes = [ ...@@ -17,10 +17,9 @@ const routes = [
path: '', path: '',
name: 'home', name: 'home',
component: () => import('../views/HomeView.vue'), component: () => import('../views/HomeView.vue'),
meta: { requiresAuth: true },
}, },
{ {
path: '/news', path: 'news',
name: 'news', name: 'news',
component: () => import('@/views/NewsView.vue'), component: () => import('@/views/NewsView.vue'),
}, },
...@@ -49,11 +48,16 @@ const routes = [ ...@@ -49,11 +48,16 @@ const routes = [
name: 'shop', name: 'shop',
component: () => import('@/views/ShopView.vue'), component: () => import('@/views/ShopView.vue'),
}, },
{
path: '/profile',
name: 'profile',
component: UserProfileView
},
{ {
path: 'admin', path: 'admin',
name: 'admin', name: 'admin',
component: () => import('@/views/TestView.vue'), component: () => import('@/views/TestView.vue'),
meta: { requiresAdmin: true } meta: { requiresAdmin: true },
}, },
{ {
path: 'unauthorized', path: 'unauthorized',
...@@ -72,11 +76,6 @@ const routes = [ ...@@ -72,11 +76,6 @@ const routes = [
name: 'login', name: 'login',
component: LoginView, component: LoginView,
}, },
{
path: '/profile',
name: 'profile',
component: UserProfileView
},
{ {
path: '/sign-up', path: '/sign-up',
name: 'sign up', name: 'sign up',
...@@ -135,18 +134,13 @@ router.beforeEach((to, from, next) => { ...@@ -135,18 +134,13 @@ router.beforeEach((to, from, next) => {
const userRole = user.role; const userRole = user.role;
const isAuthenticated = user.isLoggedIn; const isAuthenticated = user.isLoggedIn;
/*if (requiresAuth && !isAuthenticated) { if (requiresAuth && !isAuthenticated) {
next({ name: 'login' }); next({ name: 'login', query: { redirect: to.fullPath } });
} else if (requiresAdmin && userRole !== 'admin') {
next({ name: 'home' });
} else { } else {
if (requiresAdmin && userRole !== 'admin') { next();
next({ name: 'unauthorized' }); }
} else {
next();
}
}*/
next();
}); });
export default router; export default router;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment