From 19d4eb7f9e40e65f81c3586830233ce42d35c1ad Mon Sep 17 00:00:00 2001 From: DTieman Date: Mon, 24 Apr 2023 13:59:52 +0200 Subject: [PATCH] removed auth --- src/index.tsx | 9 +++----- src/utils/contexts/AuthContext.tsx | 36 ------------------------------ 2 files changed, 3 insertions(+), 42 deletions(-) delete mode 100644 src/utils/contexts/AuthContext.tsx diff --git a/src/index.tsx b/src/index.tsx index 2bcefd5..60ddaf2 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,17 +2,14 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import App from './App'; import ThemeContextProvider from "./utils/contexts/ThemeContext"; -import AuthContextProvider from "./utils/contexts/AuthContext"; const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement ); root.render( - - - - - + + + ); \ No newline at end of file diff --git a/src/utils/contexts/AuthContext.tsx b/src/utils/contexts/AuthContext.tsx deleted file mode 100644 index c1b21bc..0000000 --- a/src/utils/contexts/AuthContext.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React from "react"; - -const AUTH_URL = `http://${process.env.REACT_APP_API_URL}/auth`; - -interface IAuthContext { - sessionToken: string -} - -const AuthContext = React.createContext({ - sessionToken: '' -}); - -export const useAuth = () => React.useContext(AuthContext); - -const AuthContextProvider = ({children}: any) => { - const [sessionToken] = React.useState(''); - - React.useEffect(() => { - const token = window.localStorage.getItem('session_token'); - if (!token) { - fetch(AUTH_URL, { - method: 'GET' - }).then(res => res.json()).then(token => { - window.localStorage.setItem('session_token', token); - }); - } - }, []); - - return ( - - {children} - - ); -}; - -export default AuthContextProvider; \ No newline at end of file