From 47e3939112e251db725f830c3f36219a48c8e978 Mon Sep 17 00:00:00 2001 From: Carter Date: Wed, 23 Oct 2024 12:41:52 -0600 Subject: [PATCH] persistent login now works, no more cookie errors --- src/app/App.tsx | 6 ++++-- src/providers/LoginButton.tsx | 1 - src/providers/auth.tsx | 24 +++++++++--------------- src/providers/http.tsx | 6 +----- src/providers/pond/userAPI.tsx | 4 ++-- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/app/App.tsx b/src/app/App.tsx index 1e5a48f..7c6bf82 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -6,7 +6,7 @@ import { Auth0Provider } from '@auth0/auth0-react' import { or } from '../utils/types' import AuthWrapper from '../providers/auth' import HTTPProvider from '../providers/http' -import { useUserAPI } from '../providers/pond/userAPI' +// import { useUserAPI } from '../providers/pond/userAPI' // import LoginButton from '../providers/LoginButton' function App() { @@ -26,7 +26,7 @@ function App() { let client_id = import.meta.env.VITE_AUTH0_BXT_CLIENT_ID; console.log(url) - console.log(audience) + // console.log(audience) return ( diff --git a/src/providers/LoginButton.tsx b/src/providers/LoginButton.tsx index de1f541..c8f9aac 100644 --- a/src/providers/LoginButton.tsx +++ b/src/providers/LoginButton.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { useAuth0 } from '@auth0/auth0-react'; const LoginButton = () => { diff --git a/src/providers/auth.tsx b/src/providers/auth.tsx index 01bf9af..9f731aa 100644 --- a/src/providers/auth.tsx +++ b/src/providers/auth.tsx @@ -6,25 +6,19 @@ export default function AuthWrapper(props: PropsWithChildren<{}>) { const { children } = props; const { isLoading, loginWithRedirect, isAuthenticated, user } = useAuth0(); - useEffect(() => { + // console.log("Authenticated: ", isAuthenticated) + // console.log("Loading: ", isLoading) if (!isAuthenticated && !isLoading) { loginWithRedirect(); } - }, [isAuthenticated, loginWithRedirect]); + }, [isAuthenticated, loginWithRedirect, isLoading]); - useEffect(() => { - console.log(user) - console.log(user?.sub) - console.log(user?.picture) + if (isAuthenticated) return ( + children + ) - }, [user]) - - - - // if (isAuthenticated) return ( - // children - // ) - - return (children) + return ( +

Redirecting...

+ ) } \ No newline at end of file diff --git a/src/providers/http.tsx b/src/providers/http.tsx index c82bd94..1586e21 100644 --- a/src/providers/http.tsx +++ b/src/providers/http.tsx @@ -33,14 +33,10 @@ export default function HTTPProvider(props: PropsWithChildren) { useEffect(() => { if (isAuthenticated) getAccessTokenSilently().then(t => { - setToken(t) + setToken(t) }) }, [setToken, isAuthenticated]) - useEffect(() => { - console.log(token) - }, [token]) - const defaultOptions = (demo: boolean = false) => { if (demo || !isAuthenticated || !token) { return { diff --git a/src/providers/pond/userAPI.tsx b/src/providers/pond/userAPI.tsx index 808a2ba..ef9f18d 100644 --- a/src/providers/pond/userAPI.tsx +++ b/src/providers/pond/userAPI.tsx @@ -5,7 +5,7 @@ import { createContext, PropsWithChildren, useContext } from "react"; // import { objectQueryParams, pondURL } from "./pond"; // import { or } from "utils"; // import { useGlobalState } from "providers"; -import { AxiosResponse } from "axios"; +// import { AxiosResponse } from "axios"; import { useHTTP } from "../http"; import { pondURL } from "./pond"; @@ -50,7 +50,7 @@ export const UserAPIContext = createContext({} as IUserAPIConte export default function UserProvider(props: PropsWithChildren) { const { children } = props; - const { get, put } = useHTTP(); + const { get, /*put*/ } = useHTTP(); // const [{ as }] = useGlobalState(); // const listUsers = (