diff --git a/packages/web/src/app-router/AppRouter.tsx b/packages/web/src/app-router/AppRouter.tsx
index 3083712..ac56927 100644
--- a/packages/web/src/app-router/AppRouter.tsx
+++ b/packages/web/src/app-router/AppRouter.tsx
@@ -5,6 +5,7 @@ const LandingPage = React.lazy(() => import('../pages/landing'));
const ServersPage = React.lazy(() => import('../pages/servers'));
const PickerPage = React.lazy(() => import('../pages/picker'));
+const AuthLogin = React.lazy(() => import('../pages/auth/login'));
const MachineryNewSession = React.lazy(() => import('../pages/machinery/new-session'));
const DevToolsSetApi = React.lazy(() => import('../pages/dev-tools/set-api'));
@@ -28,6 +29,7 @@ export const AppRouter = () => {
+
{
+ const { apiUrl, fetch } = useApiContext();
+ // If ?r is in query, then let's render the slug page
+ // If not, redirect.
+ const [guildSlug, setGuildSlug] = React.useState(null);
+
+ React.useEffect(() => {
+ const url = new URL(window.location.href);
+ const redirectServerID = url.searchParams.get('r');
+ if (!redirectServerID) {
+ window.location.href = `${apiUrl}/login-bounce`;
+ return;
+ }
+
+ const fetchGuildSlug = async (id: string) => {
+ const response = await fetch(`/get-slug/${id}`);
+ if (response.status === 200) {
+ const slug = await response.json();
+ setGuildSlug(slug);
+ }
+ };
+
+ fetchGuildSlug(redirectServerID);
+ }, [apiUrl, fetch]);
+
+ if (guildSlug === null) {
+ return Loading...
;
+ }
+
+ return {}} />;
+};
+
+export default Login;
diff --git a/packages/web/src/pages/picker.tsx b/packages/web/src/pages/picker.tsx
index 2d51c59..2368c2f 100644
--- a/packages/web/src/pages/picker.tsx
+++ b/packages/web/src/pages/picker.tsx
@@ -1,3 +1,4 @@
+import { Redirect } from '@reach/router';
import { RolePickerTemplate } from '@roleypoly/design-system/templates/role-picker';
import { PresentableGuild, RoleUpdate, UserGuildPermissions } from '@roleypoly/types';
import * as React from 'react';
@@ -9,7 +10,7 @@ type PickerProps = {
};
const Picker = (props: PickerProps) => {
- const { session, authedFetch } = useSessionContext();
+ const { session, authedFetch, isAuthenticated } = useSessionContext();
const [pickerData, setPickerData] = React.useState(null);
const [pending, setPending] = React.useState(false);
@@ -25,6 +26,10 @@ const Picker = (props: PickerProps) => {
fetchPickerData();
}, [props.serverID, authedFetch]);
+ if (!isAuthenticated) {
+ return ;
+ }
+
if (pickerData === null) {
return Loading...
;
}