Skip to content

Commit

Permalink
fix: verify route on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed May 14, 2024
1 parent 3b22e6b commit 16f30a9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ export default {
darkMode(val) {
this.$vuetify.theme.dark = !!val
},
pages() {
this.verifyRoute()
},
controllerNode(node) {
if (!node) return
Expand Down Expand Up @@ -613,6 +616,27 @@ export default {
}
},
methods: {
verifyRoute() {
// ensure the actual route is available in pages otherwise redirect to the first one
if (
this.$route.meta.requiresAuth &&
this.pages.findIndex((p) => p.path === this.$route.path) === -1
) {
const preferred = ['control-panel', 'zniffer', 'settings']
const allowed = this.pages.filter((p) =>
preferred.includes(p.path),
)
const path = allowed.length ? allowed[0].path : undefined
if (path) {
this.$router.replace(path)
} else {
this.$router.replace(this.pages[0].path)
}
}
},
showNodesManager(step) {
// used in ControlPanel.vue
this.$refs.nodesManager.show(step)
Expand Down

0 comments on commit 16f30a9

Please sign in to comment.