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 TeamSvg from "../../assets/icons/user-two.svg?react";
|
||||||
import LogoutSvg from "../../assets/icons/logout.svg?react";
|
import LogoutSvg from "../../assets/icons/logout.svg?react";
|
||||||
import { Stack, useScrollTrigger } from "@mui/material";
|
import { Stack, useScrollTrigger } from "@mui/material";
|
||||||
|
import axiosIntance from "../../Utils/axiosConfig";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
const icons = {
|
const icons = {
|
||||||
Profile: <UserSvg />,
|
Profile: <UserSvg />,
|
||||||
@@ -93,10 +95,20 @@ function NavBar() {
|
|||||||
* Handles logging out the user
|
* Handles logging out the user
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const logout = () => {
|
const logout = async () => {
|
||||||
// Clear auth state
|
// Clear auth state
|
||||||
dispatch(clearAuthState());
|
dispatch(clearAuthState());
|
||||||
dispatch(clearUptimeMonitorState());
|
dispatch(clearUptimeMonitorState());
|
||||||
|
await axiosIntance.post(
|
||||||
|
"/auth/logout",
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${authState.authToken}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
navigate("/login");
|
navigate("/login");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user