Files
speckle-server/packages/frontend-2/middleware/homepage.ts
T
andrewwallacespeckle 8ca5c99aa1 Andrew/web 1338 implement new navigation (#2668)
* Initial Sidebar Implementation

* Updates to sidebar

* Use NuxtLinks in FE2 not UI-Components

* Move sidebar to component

* Active State

* Responsive menu

* Update sidebar links

* Add Projects Page. Improve routing

* Small fixes

* Responsive fixes

* TopBar refactor

* Topbar improvements

* User Menu Updates

* Responsive/Topbar improvements

* Various minor changes

* Update sidebar icon

* Revert dui3 change

* Potential fix for login issue

* Fix login issue. Improve empty state for projects

* Add Project & Workspace Invites to notification

* Revert "Add Project & Workspace Invites to notification"

This reverts commit ac33dd0cb1fc47cd5c6e2925ee2a6bbea328d94f.

* Updates to Project Invite Notifications

* Add scroll to Sidebar component

* Dashboard Card targets

* Changes to logo

* Small responsive fixes

* Remove unused alias

* Minor tidy ups

* Updates from CR

* Dashboard Header

* Add padding to non-collapsible headings

* Add Project empty state
2024-08-20 11:11:15 +01:00

27 lines
848 B
TypeScript

import { activeUserQuery } from '~~/lib/auth/composables/activeUser'
import { useApolloClientFromNuxt } from '~~/lib/common/composables/graphql'
import { convertThrowIntoFetchResult } from '~~/lib/common/helpers/graphql'
import { loginRoute } from '~~/lib/common/helpers/route'
/**
* Redirect unauthenticated users to the login page
*/
export default defineNuxtRouteMiddleware(async (to) => {
const client = useApolloClientFromNuxt()
const nuxt = useNuxtApp()
const { data } = await client
.query({
query: activeUserQuery
})
.catch(convertThrowIntoFetchResult)
if (!data?.activeUser?.id) {
if (import.meta.server && nuxt.ssrContext?.event.node.req.method === 'OPTIONS') {
// quickfix hack to prevent redirect in OPTIONS
return
}
return navigateTo({ path: loginRoute, query: to.query })
}
})