Files
baserow/web-frontend/modules/core/middleware/authenticated.js
Jérémie PardouandJonathan Adeline ca72db9a16 Nuxt3 builder fixes and cleanup (#4657)
* Fix preview error with page parameter

* Fix OIDC form support

* Fix input border color

* Fix some builder inputs

* Clear some TODO MIGs

* Clean comments

* Update snapshot

* Fix page title

* Fix reactivity issue

* refactor: replace individual RadioButtons with a RadioGroup component for choice option type selection.

* Fix domain

---------

Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
2026-02-11 11:07:26 +01:00

22 lines
665 B
JavaScript

/**
* If this middleware is added to a page, it will redirect back to the login
* page if the user is not authenticated.
*/
export default defineNuxtRouteMiddleware((to) => {
const nuxtApp = useNuxtApp()
const store = nuxtApp.$store
const event = import.meta.server ? useRequestEvent() : null
if (import.meta.server && !event) return
if (!store.getters['auth/isAuthenticated']) {
const original =
import.meta.server && event?.node?.req
? event.node.req.originalUrl || event.node.req.url || to.fullPath
: to.fullPath
const query = { original: encodeURI(original) }
return navigateTo({ name: 'login', query })
}
})