main.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import Vue from 'vue'
  2. import './plugins/vuetify'
  3. import App from './App.vue'
  4. import router from './router'
  5. import store from './store'
  6. Vue.config.productionTip = false
  7. // A function loaded before each route change
  8. router.beforeEach((to, from, next) => {
  9. // Redirect from config pages if already configured
  10. if (to.path === '/gdpr' && store.getters.isGdprValidated)
  11. return next('/hostConfig')
  12. if (to.path === '/hostConfig' && store.getters.isHostConfigured)
  13. return next('/experiments')
  14. // Redirect to configuration pages
  15. // Check GDPR before doing anything and redirect if necessary
  16. if (!store.getters.isGdprValidated) {
  17. if (to.path !== '/gdpr') return next('/gdpr')
  18. return next()
  19. }
  20. // Identify the user
  21. store.dispatch('setAppUniqueId')
  22. // Redirect if the host is not configured
  23. if (!store.getters.isHostConfigured) {
  24. if (to.path !== '/hostConfig')
  25. return next('/hostConfig')
  26. return next()
  27. }
  28. next()
  29. })
  30. new Vue({
  31. router,
  32. store,
  33. render: h => h(App)
  34. }).$mount('#app')