UPDATE/FIX: Add loading to retrieve user details before routing users to credential-sensitive pages

This commit is contained in:
Chris-1010
2025-02-23 23:08:58 +00:00
parent a27ee52de1
commit 52a15d8691

View File

@@ -19,6 +19,7 @@ function App() {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [userId, setUserId] = useState<number | null>(null);
const [username, setUsername] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
fetch("/api/user/login_status")
@@ -31,9 +32,16 @@ function App() {
.catch((error) => {
console.error("Error fetching login status:", error);
setIsLoggedIn(false);
})
.finally(() => {
setIsLoading(false);
});
}, []);
if (isLoading) {
return <div className="flex w-full h-full">Loading...</div>;
}
return (
<Brightness>
<AuthContext.Provider