From 501f94ab5de2c5985e009d611a30cdf24de3b1be Mon Sep 17 00:00:00 2001 From: Theis Gaedigk Date: Fri, 29 May 2026 22:18:02 +0200 Subject: [PATCH] improved frontend routing --- frontend/src/routes/app/_hiddenLayout/app-settings.tsx | 10 +++++++++- frontend/src/routes/app/_hiddenLayout/storages.tsx | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/app/_hiddenLayout/app-settings.tsx b/frontend/src/routes/app/_hiddenLayout/app-settings.tsx index d5a542e..f978f79 100644 --- a/frontend/src/routes/app/_hiddenLayout/app-settings.tsx +++ b/frontend/src/routes/app/_hiddenLayout/app-settings.tsx @@ -1,7 +1,15 @@ -import { createFileRoute } from "@tanstack/react-router"; +import { createFileRoute, redirect } from "@tanstack/react-router"; +import { isAuthenticated } from "../../../utils/auth"; import { Settings } from "../../../pages/Settings"; export const Route = createFileRoute("/app/_hiddenLayout/app-settings")({ + beforeLoad: async () => { + if (!(await isAuthenticated())) { + throw redirect({ + to: "/login", + }); + } + }, component: RouteComponent, }); diff --git a/frontend/src/routes/app/_hiddenLayout/storages.tsx b/frontend/src/routes/app/_hiddenLayout/storages.tsx index aedf9de..23a7c33 100644 --- a/frontend/src/routes/app/_hiddenLayout/storages.tsx +++ b/frontend/src/routes/app/_hiddenLayout/storages.tsx @@ -1,7 +1,15 @@ -import { createFileRoute } from "@tanstack/react-router"; +import { createFileRoute, redirect } from "@tanstack/react-router"; +import { isAuthenticated } from "../../../utils/auth"; import { Storages } from "../../../pages/Storages"; export const Route = createFileRoute("/app/_hiddenLayout/storages")({ + beforeLoad: async () => { + if (!(await isAuthenticated())) { + throw redirect({ + to: "/login", + }); + } + }, component: RouteComponent, });