(null);
@@ -17,6 +20,9 @@ const Login = () => {
const redirectServerID = url.searchParams.get('r');
const redirectUrl = `${apiUrl}/login-bounce?cbh=${callbackHost.href}`;
if (!redirectServerID) {
+ if (isAuthenticated) {
+ redirectTo('/servers');
+ }
window.location.href = redirectUrl;
return;
}
@@ -33,7 +39,11 @@ const Login = () => {
};
fetchGuildSlug(redirectServerID);
- }, [apiUrl, fetch]);
+
+ if (isAuthenticated) {
+ redirectTo(`/s/${redirectServerID}`);
+ }
+ }, [apiUrl, fetch, isAuthenticated]);
if (guildSlug === null) {
return Loading...
;
diff --git a/packages/web/src/pages/landing.tsx b/packages/web/src/pages/landing.tsx
index f663d9f..fecbfb3 100644
--- a/packages/web/src/pages/landing.tsx
+++ b/packages/web/src/pages/landing.tsx
@@ -10,7 +10,7 @@ const Landing = () => {
const appShellProps = useAppShellProps();
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
index 959f80f..798b177 100644
--- a/packages/web/src/pages/machinery/new-session.tsx
+++ b/packages/web/src/pages/machinery/new-session.tsx
@@ -1,22 +1,32 @@
+import { Redirect } from '@reach/router';
import * as React from 'react';
+import { useSessionContext } from '../../contexts/session/SessionContext';
import { Title } from '../../utils/metaTitle';
-const NewSession = () => {
+const NewSession = (props: { sessionID: string }) => {
+ const session = useSessionContext();
+ const [postauthUrl, setPostauthUrl] = React.useState('/servers');
+
React.useEffect(() => {
const url = new URL(window.location.href);
- const id = url.searchParams.get('session_id');
+ const id = props.sessionID || url.searchParams.get('session_id');
if (id) {
localStorage.setItem('rp_session_key', id);
+ session.setSession({ sessionID: id });
- const redirectUrl = localStorage.getItem('rp_postauth_redirect');
- window.location.href = redirectUrl || '/';
+ const storedPostauthUrl = localStorage.getItem('rp_postauth_redirect');
+ if (storedPostauthUrl) {
+ setPostauthUrl(storedPostauthUrl);
+ localStorage.removeItem('rp_postauth_redirect');
+ }
}
- });
+ }, [setPostauthUrl, props.sessionID, session]);
return (
<>
- Redirecting you...
+ Logging you into Roleypoly...
+ {session.isAuthenticated && }
>
);
};