Adds auth guards
This commit is contained in:
@@ -13,10 +13,11 @@
|
||||
import { Route as rootRoute } from './routes/__root'
|
||||
import { Route as LoginImport } from './routes/login'
|
||||
import { Route as AboutImport } from './routes/about'
|
||||
import { Route as AuthenticatedImport } from './routes/_authenticated'
|
||||
import { Route as IndexImport } from './routes/index'
|
||||
import { Route as SessionsIndexImport } from './routes/sessions.index'
|
||||
import { Route as CampaignsIndexImport } from './routes/campaigns.index'
|
||||
import { Route as CampaignsCampaignIdImport } from './routes/campaigns.$campaignId'
|
||||
import { Route as AuthenticatedSessionsIndexImport } from './routes/_authenticated/sessions.index'
|
||||
import { Route as AuthenticatedCampaignsIndexImport } from './routes/_authenticated/campaigns.index'
|
||||
import { Route as AuthenticatedCampaignsCampaignIdImport } from './routes/_authenticated/campaigns.$campaignId'
|
||||
|
||||
// Create/Update Routes
|
||||
|
||||
@@ -32,29 +33,38 @@ const AboutRoute = AboutImport.update({
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const AuthenticatedRoute = AuthenticatedImport.update({
|
||||
id: '/_authenticated',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const IndexRoute = IndexImport.update({
|
||||
id: '/',
|
||||
path: '/',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const SessionsIndexRoute = SessionsIndexImport.update({
|
||||
id: '/sessions/',
|
||||
path: '/sessions/',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
const AuthenticatedSessionsIndexRoute = AuthenticatedSessionsIndexImport.update(
|
||||
{
|
||||
id: '/sessions/',
|
||||
path: '/sessions/',
|
||||
getParentRoute: () => AuthenticatedRoute,
|
||||
} as any,
|
||||
)
|
||||
|
||||
const CampaignsIndexRoute = CampaignsIndexImport.update({
|
||||
id: '/campaigns/',
|
||||
path: '/campaigns/',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
const AuthenticatedCampaignsIndexRoute =
|
||||
AuthenticatedCampaignsIndexImport.update({
|
||||
id: '/campaigns/',
|
||||
path: '/campaigns/',
|
||||
getParentRoute: () => AuthenticatedRoute,
|
||||
} as any)
|
||||
|
||||
const CampaignsCampaignIdRoute = CampaignsCampaignIdImport.update({
|
||||
id: '/campaigns/$campaignId',
|
||||
path: '/campaigns/$campaignId',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
const AuthenticatedCampaignsCampaignIdRoute =
|
||||
AuthenticatedCampaignsCampaignIdImport.update({
|
||||
id: '/campaigns/$campaignId',
|
||||
path: '/campaigns/$campaignId',
|
||||
getParentRoute: () => AuthenticatedRoute,
|
||||
} as any)
|
||||
|
||||
// Populate the FileRoutesByPath interface
|
||||
|
||||
@@ -67,6 +77,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof IndexImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/_authenticated': {
|
||||
id: '/_authenticated'
|
||||
path: ''
|
||||
fullPath: ''
|
||||
preLoaderRoute: typeof AuthenticatedImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/about': {
|
||||
id: '/about'
|
||||
path: '/about'
|
||||
@@ -81,64 +98,84 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof LoginImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/campaigns/$campaignId': {
|
||||
id: '/campaigns/$campaignId'
|
||||
'/_authenticated/campaigns/$campaignId': {
|
||||
id: '/_authenticated/campaigns/$campaignId'
|
||||
path: '/campaigns/$campaignId'
|
||||
fullPath: '/campaigns/$campaignId'
|
||||
preLoaderRoute: typeof CampaignsCampaignIdImport
|
||||
parentRoute: typeof rootRoute
|
||||
preLoaderRoute: typeof AuthenticatedCampaignsCampaignIdImport
|
||||
parentRoute: typeof AuthenticatedImport
|
||||
}
|
||||
'/campaigns/': {
|
||||
id: '/campaigns/'
|
||||
'/_authenticated/campaigns/': {
|
||||
id: '/_authenticated/campaigns/'
|
||||
path: '/campaigns'
|
||||
fullPath: '/campaigns'
|
||||
preLoaderRoute: typeof CampaignsIndexImport
|
||||
parentRoute: typeof rootRoute
|
||||
preLoaderRoute: typeof AuthenticatedCampaignsIndexImport
|
||||
parentRoute: typeof AuthenticatedImport
|
||||
}
|
||||
'/sessions/': {
|
||||
id: '/sessions/'
|
||||
'/_authenticated/sessions/': {
|
||||
id: '/_authenticated/sessions/'
|
||||
path: '/sessions'
|
||||
fullPath: '/sessions'
|
||||
preLoaderRoute: typeof SessionsIndexImport
|
||||
parentRoute: typeof rootRoute
|
||||
preLoaderRoute: typeof AuthenticatedSessionsIndexImport
|
||||
parentRoute: typeof AuthenticatedImport
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create and export the route tree
|
||||
|
||||
interface AuthenticatedRouteChildren {
|
||||
AuthenticatedCampaignsCampaignIdRoute: typeof AuthenticatedCampaignsCampaignIdRoute
|
||||
AuthenticatedCampaignsIndexRoute: typeof AuthenticatedCampaignsIndexRoute
|
||||
AuthenticatedSessionsIndexRoute: typeof AuthenticatedSessionsIndexRoute
|
||||
}
|
||||
|
||||
const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {
|
||||
AuthenticatedCampaignsCampaignIdRoute: AuthenticatedCampaignsCampaignIdRoute,
|
||||
AuthenticatedCampaignsIndexRoute: AuthenticatedCampaignsIndexRoute,
|
||||
AuthenticatedSessionsIndexRoute: AuthenticatedSessionsIndexRoute,
|
||||
}
|
||||
|
||||
const AuthenticatedRouteWithChildren = AuthenticatedRoute._addFileChildren(
|
||||
AuthenticatedRouteChildren,
|
||||
)
|
||||
|
||||
export interface FileRoutesByFullPath {
|
||||
'/': typeof IndexRoute
|
||||
'': typeof AuthenticatedRouteWithChildren
|
||||
'/about': typeof AboutRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/campaigns/$campaignId': typeof CampaignsCampaignIdRoute
|
||||
'/campaigns': typeof CampaignsIndexRoute
|
||||
'/sessions': typeof SessionsIndexRoute
|
||||
'/campaigns/$campaignId': typeof AuthenticatedCampaignsCampaignIdRoute
|
||||
'/campaigns': typeof AuthenticatedCampaignsIndexRoute
|
||||
'/sessions': typeof AuthenticatedSessionsIndexRoute
|
||||
}
|
||||
|
||||
export interface FileRoutesByTo {
|
||||
'/': typeof IndexRoute
|
||||
'': typeof AuthenticatedRouteWithChildren
|
||||
'/about': typeof AboutRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/campaigns/$campaignId': typeof CampaignsCampaignIdRoute
|
||||
'/campaigns': typeof CampaignsIndexRoute
|
||||
'/sessions': typeof SessionsIndexRoute
|
||||
'/campaigns/$campaignId': typeof AuthenticatedCampaignsCampaignIdRoute
|
||||
'/campaigns': typeof AuthenticatedCampaignsIndexRoute
|
||||
'/sessions': typeof AuthenticatedSessionsIndexRoute
|
||||
}
|
||||
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRoute
|
||||
'/': typeof IndexRoute
|
||||
'/_authenticated': typeof AuthenticatedRouteWithChildren
|
||||
'/about': typeof AboutRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/campaigns/$campaignId': typeof CampaignsCampaignIdRoute
|
||||
'/campaigns/': typeof CampaignsIndexRoute
|
||||
'/sessions/': typeof SessionsIndexRoute
|
||||
'/_authenticated/campaigns/$campaignId': typeof AuthenticatedCampaignsCampaignIdRoute
|
||||
'/_authenticated/campaigns/': typeof AuthenticatedCampaignsIndexRoute
|
||||
'/_authenticated/sessions/': typeof AuthenticatedSessionsIndexRoute
|
||||
}
|
||||
|
||||
export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath
|
||||
fullPaths:
|
||||
| '/'
|
||||
| ''
|
||||
| '/about'
|
||||
| '/login'
|
||||
| '/campaigns/$campaignId'
|
||||
@@ -147,6 +184,7 @@ export interface FileRouteTypes {
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to:
|
||||
| '/'
|
||||
| ''
|
||||
| '/about'
|
||||
| '/login'
|
||||
| '/campaigns/$campaignId'
|
||||
@@ -155,30 +193,27 @@ export interface FileRouteTypes {
|
||||
id:
|
||||
| '__root__'
|
||||
| '/'
|
||||
| '/_authenticated'
|
||||
| '/about'
|
||||
| '/login'
|
||||
| '/campaigns/$campaignId'
|
||||
| '/campaigns/'
|
||||
| '/sessions/'
|
||||
| '/_authenticated/campaigns/$campaignId'
|
||||
| '/_authenticated/campaigns/'
|
||||
| '/_authenticated/sessions/'
|
||||
fileRoutesById: FileRoutesById
|
||||
}
|
||||
|
||||
export interface RootRouteChildren {
|
||||
IndexRoute: typeof IndexRoute
|
||||
AuthenticatedRoute: typeof AuthenticatedRouteWithChildren
|
||||
AboutRoute: typeof AboutRoute
|
||||
LoginRoute: typeof LoginRoute
|
||||
CampaignsCampaignIdRoute: typeof CampaignsCampaignIdRoute
|
||||
CampaignsIndexRoute: typeof CampaignsIndexRoute
|
||||
SessionsIndexRoute: typeof SessionsIndexRoute
|
||||
}
|
||||
|
||||
const rootRouteChildren: RootRouteChildren = {
|
||||
IndexRoute: IndexRoute,
|
||||
AuthenticatedRoute: AuthenticatedRouteWithChildren,
|
||||
AboutRoute: AboutRoute,
|
||||
LoginRoute: LoginRoute,
|
||||
CampaignsCampaignIdRoute: CampaignsCampaignIdRoute,
|
||||
CampaignsIndexRoute: CampaignsIndexRoute,
|
||||
SessionsIndexRoute: SessionsIndexRoute,
|
||||
}
|
||||
|
||||
export const routeTree = rootRoute
|
||||
@@ -192,30 +227,39 @@ export const routeTree = rootRoute
|
||||
"filePath": "__root.tsx",
|
||||
"children": [
|
||||
"/",
|
||||
"/_authenticated",
|
||||
"/about",
|
||||
"/login",
|
||||
"/campaigns/$campaignId",
|
||||
"/campaigns/",
|
||||
"/sessions/"
|
||||
"/login"
|
||||
]
|
||||
},
|
||||
"/": {
|
||||
"filePath": "index.tsx"
|
||||
},
|
||||
"/_authenticated": {
|
||||
"filePath": "_authenticated.tsx",
|
||||
"children": [
|
||||
"/_authenticated/campaigns/$campaignId",
|
||||
"/_authenticated/campaigns/",
|
||||
"/_authenticated/sessions/"
|
||||
]
|
||||
},
|
||||
"/about": {
|
||||
"filePath": "about.tsx"
|
||||
},
|
||||
"/login": {
|
||||
"filePath": "login.tsx"
|
||||
},
|
||||
"/campaigns/$campaignId": {
|
||||
"filePath": "campaigns.$campaignId.tsx"
|
||||
"/_authenticated/campaigns/$campaignId": {
|
||||
"filePath": "_authenticated/campaigns.$campaignId.tsx",
|
||||
"parent": "/_authenticated"
|
||||
},
|
||||
"/campaigns/": {
|
||||
"filePath": "campaigns.index.tsx"
|
||||
"/_authenticated/campaigns/": {
|
||||
"filePath": "_authenticated/campaigns.index.tsx",
|
||||
"parent": "/_authenticated"
|
||||
},
|
||||
"/sessions/": {
|
||||
"filePath": "sessions.index.tsx"
|
||||
"/_authenticated/sessions/": {
|
||||
"filePath": "_authenticated/sessions.index.tsx",
|
||||
"parent": "/_authenticated"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user