Logout calls back-end

This commit is contained in:
JBB0807 2025-05-01 13:32:12 -07:00
parent a310f71311
commit 599182ab91

View file

@ -1,7 +1,7 @@
import React, { useState, useEffect, useRef } from "react";
import "../scss/styles.scss";
import "../scss/components/_navbar.scss";
import { Link, useNavigate } from "react-router-dom";
import { Link } from "react-router-dom";
const Navbar = () => {
const [glitchEffect, setGlitchEffect] = useState(false);
@ -9,23 +9,9 @@ const Navbar = () => {
const [user, setUser] = useState(null);
const [menuOpen, setMenuOpen] = useState(false);
const menuRef = useRef(null);
const navigate = useNavigate();
const handleLogout = () => {
// Implement client-side logout without calling the backend
// This clears the user state in the frontend
setUser(null);
// Clear any authentication cookies if they exist
document.cookie.split(";").forEach((cookie) => {
const [name] = cookie.trim().split("=");
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
});
// Redirect to home page
navigate("/");
console.log("Logged out successfully");
async function handleLogout() {
window.open("http://localhost:8080/auth/logout", "_self");
};
useEffect(() => {