GuidedSetup.vue 996 B

123456789101112131415161718192021222324252627282930313233
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { useAuthenticationStore } from '#shared/stores/authentication.ts'
  4. import { useSessionStore } from '#shared/stores/session.ts'
  5. import { useSystemSetupInfoStore } from '../stores/systemSetupInfo.ts'
  6. defineOptions({
  7. async beforeRouteEnter(to) {
  8. const { authenticated } = useAuthenticationStore()
  9. const { hasPermission } = useSessionStore()
  10. if (authenticated && !hasPermission('admin.wizard')) {
  11. return { path: '/', replace: true }
  12. }
  13. await useSystemSetupInfoStore().setSystemSetupInfo()
  14. const systemSetupInfo = useSystemSetupInfoStore()
  15. if (systemSetupInfo.systemSetupDone) {
  16. return to.meta.requiresAuth ? true : { path: '/login', replace: true }
  17. }
  18. if (systemSetupInfo.redirectNeeded(to.path)) {
  19. return { path: systemSetupInfo.redirectPath, replace: true }
  20. }
  21. },
  22. })
  23. </script>
  24. <template>
  25. <RouterView />
  26. </template>