Skip to content
Snippets Groups Projects
Commit 0788fc65 authored by Titus Netland's avatar Titus Netland
Browse files

Fixed guard route

parent d11a848c
No related branches found
No related tags found
1 merge request!24Fixed guard route
Pipeline #176541 passed with stages
in 1 minute and 30 seconds
......@@ -9,12 +9,11 @@ import NewPasswordView from "../views/NewPasswordView";
* login page and the register page will be accessible.
*/
function guardRoute(to, from, next) {
var isAuthenticated = false;
if (store.state.user.token != null) isAuthenticated = true;
else isAuthenticated = false;
let isAuthenticated = store.state.user.token != null;
if (isAuthenticated) {
next(); // allow to enter route
} else {
}
else {
next("/login"); // go to '/login';
}
}
......@@ -23,13 +22,11 @@ const routes = [
{
path: "/", //Endre før push
name: "home",
beforeEnter: guardRoute,
component: HomeView,
},
{
path: "/about",
name: "about",
beforeEnter: guardRoute,
component: () => import("../views/AboutView.vue"),
},
{
......@@ -58,7 +55,6 @@ const routes = [
path: "/searchItemList",
name: "searchItemList",
component: () => import("../views/SearchItemListView.vue"),
beforeEnter: guardRoute,
},
{
path: "/createNewGroup",
......@@ -76,11 +72,13 @@ const routes = [
path: "/notifications",
name: "notifications",
component: () => import("../views/NotificationView.vue"),
beforeEnter: guardRoute,
},
{
path: "/messages",
name: "messages",
component: () => import("../views/MessagesView.vue"),
beforeEnter: guardRoute,
},
];
......
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