New Backend changes

This commit is contained in:
2025-08-31 18:28:59 +02:00
parent b0497142ed
commit 6d76acc0bc
26 changed files with 813 additions and 1379 deletions

17
middleware/auth.global.ts Normal file
View File

@@ -0,0 +1,17 @@
export default defineNuxtRouteMiddleware(async (to, from) => {
const auth = useAuthStore()
// Wenn nicht eingeloggt → auf /login (außer er will schon dahin)
if (!auth.user && !["/login", "/password-reset"].includes(to.path)) {
return navigateTo("/login")
}
// Wenn eingeloggt → von /login auf /dashboard umleiten
if (auth.user && !auth.user?.must_change_password && to.path === "/login") {
return navigateTo("/")
} else if(auth.user && auth.user.must_change_password && to.path !== "/password-change") {
return navigateTo("/password-change")
}
})

View File

@@ -1,8 +0,0 @@
export default defineNuxtRouteMiddleware((to, _from) => {
const user = useSupabaseUser()
const router = useRouter()
if (!user.value) {
//useCookie('redirect', { path: '/' }).value = to.fullPath
return router.push("/login")
}
})

View File

@@ -1,9 +0,0 @@
export default defineNuxtRouteMiddleware(async (to, _from) => {
const router = useRouter()
console.log(await useCapacitor().getIsPhone())
if(await useCapacitor().getIsPhone()) {
return router.push('/mobile')
}
})