routes.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { RouteRecordRaw } from 'vue-router'
  3. export const isMainRoute = true
  4. const route: RouteRecordRaw[] = [
  5. {
  6. path: '/login',
  7. name: 'Login',
  8. component: () => import('./views/Login.vue'),
  9. meta: {
  10. title: __('Sign in'),
  11. requiresAuth: false,
  12. requiredPermission: null,
  13. hasOwnLandmarks: true,
  14. },
  15. },
  16. {
  17. path: '/login/after-auth',
  18. name: 'LoginAfterAuth',
  19. component: () => import('./views/LoginAfterAuth.vue'),
  20. async beforeEnter(to) {
  21. // don't open the page if there is nothing to show
  22. const { useAfterAuthPlugins } = await import(
  23. './after-auth/composable/useAfterAuthPlugins.ts'
  24. )
  25. const { currentPlugin } = useAfterAuthPlugins()
  26. if (!currentPlugin.value) {
  27. return to.redirectedFrom ? false : '/'
  28. }
  29. },
  30. meta: {
  31. requiresAuth: false,
  32. requiredPermission: null,
  33. hasOwnLandmarks: true,
  34. },
  35. },
  36. {
  37. path: '/logout',
  38. name: 'Logout',
  39. component: {
  40. async beforeRouteEnter() {
  41. const [{ useAuthenticationStore }, { useNotifications }] =
  42. await Promise.all([
  43. import('#shared/stores/authentication.ts'),
  44. import(
  45. '#shared/components/CommonNotifications/useNotifications.ts'
  46. ),
  47. ])
  48. const { clearAllNotifications } = useNotifications()
  49. const authentication = useAuthenticationStore()
  50. clearAllNotifications()
  51. await authentication.logout()
  52. if (authentication.externalLogout) return false
  53. return '/login'
  54. },
  55. },
  56. meta: {
  57. requiresAuth: false,
  58. requiredPermission: null,
  59. },
  60. },
  61. ]
  62. export default route