mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
fix(app): wait for the session before redirecting from /app (#3404)
This commit is contained in:
1 parent
e87b593f46
commit
d59ddc2214
1 file changed
+9
-7
@@ -9,6 +9,13 @@ import {getDefaultLandingPath} from '@app/features/navigation/utils/DefaultLandi
|
|||||||
import {createRootRoute, createRoute} from '@app/features/platform/components/router/RouterBuilder';
|
import {createRootRoute, createRoute} from '@app/features/platform/components/router/RouterBuilder';
|
||||||
import {Redirect} from '@app/features/platform/components/router/RouterTypes';
|
import {Redirect} from '@app/features/platform/components/router/RouterTypes';
|
||||||
|
|
||||||
|
const enterDefaultLanding = afterSessionInitialization(() => {
|
||||||
|
if (readAuthenticatedRuntimeContext() === null) {
|
||||||
|
return new Redirect(Routes.LOGIN);
|
||||||
|
}
|
||||||
|
return new Redirect(getDefaultLandingPath());
|
||||||
|
});
|
||||||
|
|
||||||
export const rootRoute = createRootRoute({
|
export const rootRoute = createRootRoute({
|
||||||
layout: ({children}) => (
|
layout: ({children}) => (
|
||||||
<RootComponent data-flx="app.router.root-routes.layout.root-component">{children}</RootComponent>
|
<RootComponent data-flx="app.router.root-routes.layout.root-component">{children}</RootComponent>
|
||||||
@@ -23,16 +30,11 @@ export const homeRoute = createRoute({
|
|||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
id: 'home',
|
id: 'home',
|
||||||
path: '/',
|
path: '/',
|
||||||
onEnter: afterSessionInitialization(() => {
|
onEnter: enterDefaultLanding,
|
||||||
if (readAuthenticatedRuntimeContext() === null) {
|
|
||||||
return new Redirect(Routes.LOGIN);
|
|
||||||
}
|
|
||||||
return new Redirect(getDefaultLandingPath());
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
export const appRoute = createRoute({
|
export const appRoute = createRoute({
|
||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
id: 'app',
|
id: 'app',
|
||||||
path: Routes.APP,
|
path: Routes.APP,
|
||||||
onEnter: () => new Redirect(getDefaultLandingPath()),
|
onEnter: enterDefaultLanding,
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user