Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/bad site routes #108

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '@/store/index'

import Home from './views/Home.vue'
import Profile from './views/Profile.vue'
Expand All @@ -21,6 +22,8 @@ import UserData from './views/UserData.vue'
import NotFound from './views/NotFound'
import Remotehq from './views/Remotehq'

import _ from 'lodash'

Vue.use(VueRouter)

const router = new VueRouter({
Expand All @@ -47,6 +50,12 @@ const router = new VueRouter({
{
path: '/cr/:sitecode',
name: 'controlroom',
beforeEnter: (to, from, next) => {
if (!_.includes(store.getters['site_config/available_sites'], to.params.sitecode)) {
return next('/')
}
next()
},
component: ControlRoom,
props: route => {
return {
Expand All @@ -57,6 +66,12 @@ const router = new VueRouter({
{
path: '/site/:sitecode/:subpage',
name: 'site',
beforeEnter: (to, from, next) => {
if (!_.includes(store.getters['site_config/available_sites'], to.params.sitecode)) {
return next('/')
}
next()
},
component: Site,
props: route => {
return {
Expand Down
Loading