front and back work
This commit is contained in:
@@ -28,16 +28,11 @@ import { logOut } from './reducers/auth';
|
||||
|
||||
const App = () => {
|
||||
useEffect(() => {
|
||||
// check for token in LS when app first runs
|
||||
if (localStorage.token) {
|
||||
// if there is a token set axios headers for all requests
|
||||
setAuthToken(localStorage.token);
|
||||
}
|
||||
// try to fetch a user, if no token or invalid token we
|
||||
// will get a 401 response from our API
|
||||
store.dispatch(loadUser());
|
||||
|
||||
// log user out from all tabs if they log out in one tab
|
||||
window.addEventListener("storage", () => {
|
||||
if (!localStorage.token) store.dispatch(logOut);
|
||||
});
|
||||
@@ -80,17 +75,6 @@ const App = () => {
|
||||
</Router>
|
||||
</Provider>
|
||||
);
|
||||
/*
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<Router>
|
||||
<Routes>
|
||||
<Route path="login" element={<Login />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
</Provider>
|
||||
);
|
||||
*/
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
Reference in New Issue
Block a user