diff --git a/packages/web/src/app-router/AppRouter.tsx b/packages/web/src/app-router/AppRouter.tsx index 01f752c..60346e5 100644 --- a/packages/web/src/app-router/AppRouter.tsx +++ b/packages/web/src/app-router/AppRouter.tsx @@ -4,6 +4,7 @@ import * as React from 'react'; const LandingPage = React.lazy(() => import('../pages/landing')); const DevToolsSetApi = React.lazy(() => import('../pages/dev-tools/set-api')); const DevToolsSessionDebug = React.lazy(() => import('../pages/dev-tools/session-debug')); +const MachineryNewSession = React.lazy(() => import('../pages/machinery/new-session')); const RouteWrapper = (props: { component: React.LazyExoticComponent>; @@ -19,6 +20,7 @@ export const AppRouter = () => { return ( + { const session = useSessionContext(); + const api = useApiContext(); return (
             {JSON.stringify(
                 {
-                    isAuthenticated: !!session.session?.user,
+                    apiUrl: api.apiUrl,
+                    isAuthenticated: session.isAuthenticated,
                     user: session.session?.user || null,
                     guilds: session.session?.guilds || null,
                 },
diff --git a/packages/web/src/pages/landing.tsx b/packages/web/src/pages/landing.tsx
index 659f5c6..3c41438 100644
--- a/packages/web/src/pages/landing.tsx
+++ b/packages/web/src/pages/landing.tsx
@@ -1,7 +1,16 @@
+import { Redirect } from '@reach/router';
 import { LandingTemplate } from '@roleypoly/design-system/templates/landing';
 import * as React from 'react';
+import { useSessionContext } from '../session-context/SessionContext';
 
 const Landing = () => {
+    const { isAuthenticated } = useSessionContext();
+
+    if (isAuthenticated) {
+        // return ;
+        return ;
+    }
+
     return ;
 };
 
diff --git a/packages/web/src/pages/machinery/new-session.tsx b/packages/web/src/pages/machinery/new-session.tsx
new file mode 100644
index 0000000..5075e2f
--- /dev/null
+++ b/packages/web/src/pages/machinery/new-session.tsx
@@ -0,0 +1,16 @@
+import * as React from 'react';
+
+const NewSession = () => {
+    React.useEffect(() => {
+        const url = new URL(window.location.href);
+        const id = url.searchParams.get('session_id');
+        if (id) {
+            window.location.href = '/';
+            localStorage.setItem('rp_session_key', id);
+        }
+    });
+
+    return 
Redirecting you...
; +}; + +export default NewSession; diff --git a/packages/web/src/session-context/SessionContext.tsx b/packages/web/src/session-context/SessionContext.tsx index 0c859b5..511458f 100644 --- a/packages/web/src/session-context/SessionContext.tsx +++ b/packages/web/src/session-context/SessionContext.tsx @@ -6,9 +6,11 @@ type SessionContextT = { session?: Omit, 'tokens'>; setSession: (session?: SessionContextT['session']) => void; authedFetch: (url: string, opts?: RequestInit) => Promise; + isAuthenticated: boolean; }; const SessionContext = React.createContext({ + isAuthenticated: false, setSession: () => {}, authedFetch: async () => { return new Response(); @@ -36,6 +38,7 @@ export const SessionContextProvider = (props: { children: React.ReactNode }) => }, }); }, + isAuthenticated: !!session && !!session.sessionID && !!session.user, }), [session, api] );