Skip to content

Commit

Permalink
Merge pull request #108 from LCOGT/fix/bad-site-routes
Browse files Browse the repository at this point in the history
Fix/bad site routes
  • Loading branch information
capetillo authored Oct 10, 2023
2 parents 60faec2 + 5fd71e3 commit 4284ba9
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit 4284ba9

Please sign in to comment.