Add post request to logout
This commit is contained in:
1 parent
9fe75c92dd
commit
68164b9362
1 file changed
+13
-1
@@ -21,6 +21,8 @@ import UserSvg from "../../assets/icons/user.svg?react";
|
||||
import TeamSvg from "../../assets/icons/user-two.svg?react";
|
||||
import LogoutSvg from "../../assets/icons/logout.svg?react";
|
||||
import { Stack, useScrollTrigger } from "@mui/material";
|
||||
import axiosIntance from "../../Utils/axiosConfig";
|
||||
import axios from "axios";
|
||||
|
||||
const icons = {
|
||||
Profile: <UserSvg />,
|
||||
@@ -93,10 +95,20 @@ function NavBar() {
|
||||
* Handles logging out the user
|
||||
*
|
||||
*/
|
||||
const logout = () => {
|
||||
const logout = async () => {
|
||||
// Clear auth state
|
||||
dispatch(clearAuthState());
|
||||
dispatch(clearUptimeMonitorState());
|
||||
await axiosIntance.post(
|
||||
"/auth/logout",
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${authState.authToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
navigate("/login");
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user