Commit 9b875917 authored by Ermolaev Timur's avatar Ermolaev Timur

#92 исправил ошибку при выходе из профиля

parent 37bf7db6
......@@ -100,6 +100,7 @@ router.delete('/sessions', async(req: Request, res: Response):Promise<void | obj
if(!user) return res.send({successMsg});
user.token = nanoid();
await user.save();
return res.send(successMsg)
})
......
......@@ -18,8 +18,8 @@ const ProfileBlock = () => {
setAnchorEl(null);
};
const logout = async () => {
await dispatch(logoutUser(navigate));
const logout = () => {
dispatch(logoutUser(navigate));
handleClose()
}
return <>
......@@ -37,7 +37,7 @@ const ProfileBlock = () => {
>
<MenuItem component={NavLink} to="/profile/test" color="inherit" onClick={handleClose}>Profile</MenuItem>
<MenuItem onClick={logout}>Logout</MenuItem>
<MenuItem onClick={()=>{logout()}}>Logout</MenuItem>
</Menu>
</>
};
......
......@@ -85,13 +85,9 @@ export const forgottenPassword = (userData, navigate) => {
}
export const logoutUser = (navigate) => {
return async (dispatch, getState) => {
return async (dispatch) => {
try {
await axios.delete("/users/sessions", {
headers: {
'Authorization': getState().users.user?.token
}
});
await axios.delete("/users/sessions");
dispatch(logoutUserSuccess());
navigate("/");
dispatch(showNotification("Вы успешно вышли"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment