diff --git a/ui/src/components/AuthenticationGateway.tsx b/ui/src/components/AuthenticationGateway.tsx
index f54703b..2bd73a8 100644
--- a/ui/src/components/AuthenticationGateway.tsx
+++ b/ui/src/components/AuthenticationGateway.tsx
@@ -1,11 +1,11 @@
import { useEffect, useState } from "react";
import { Navigate, Outlet, useSearchParams } from "react-router-dom";
import { match } from "ts-pattern";
-import { useSession } from "../contexts/SessionContext";
import { LoadingSpinner } from "./LoadingSpinner";
+import { useMaybeUser } from "@ui/providers/UserStoreProvider";
export const AuthenticationGateway = () => {
- const { session } = useSession();
+ const user = useMaybeUser();
const [isLoading, setIsLoading] = useState(true);
const [searchParams] = useSearchParams();
@@ -20,24 +20,20 @@ export const AuthenticationGateway = () => {
setIsLoading(false);
}, 200);
return () => clearTimeout(timer);
- }, [session]);
+ }, [user]);
let status: "loading" | "should-redirect" | "should-pass" = "loading";
if (isLoading) {
status = "loading";
- } else if (session?.user) {
+ } else if (user) {
status = "should-redirect";
} else {
status = "should-pass";
}
- return (
- <>
- {match(status)
- .with("loading", () => )
- .with("should-redirect", () => )
- .with("should-pass", () => )
- .exhaustive()}
- >
- );
+ return match(status)
+ .with("loading", () => )
+ .with("should-redirect", () => )
+ .with("should-pass", () => )
+ .exhaustive();
};