Logout calls back-end
This commit is contained in:
parent
a310f71311
commit
599182ab91
1 changed files with 3 additions and 17 deletions
|
|
@ -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(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue