front and back work

This commit is contained in:
QkoSad
2023-07-29 18:29:41 +03:00
parent 40051f9d5e
commit 2fee49e583
9 changed files with 29 additions and 26 deletions
-16
View File
@@ -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;