Merge pull request #4743 from BerriAI/ui_fix_logout

[UI] Clear cookies on logging out
This commit is contained in:
Ishaan Jaff
2024-07-16 17:56:37 -07:00
committed by GitHub
2 changed files with 10 additions and 6 deletions
@@ -31,6 +31,9 @@ const Sidebar: React.FC<SidebarProps> = ({
<Menu.Item key="1" onClick={() => setPage("usage")}>
Usage
</Menu.Item>
<Menu.Item key="9" onClick={() => setPage("caching")}>
<Text>Caching</Text>
</Menu.Item>
</Menu>
</Sider>
</Layout>
@@ -57,7 +57,12 @@ const Navbar: React.FC<NavbarProps> = ({
console.log("logoutUrl=", logoutUrl);
const handleLogout = () => {
// Clear cookies
document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
window.location.href = logoutUrl;
}
const items: MenuProps["items"] = [
{
@@ -72,11 +77,7 @@ const Navbar: React.FC<NavbarProps> = ({
},
{
key: "2",
label: (
<a href={logoutUrl}>
<p>Logout</p>
</a>
),
label: <p onClick={handleLogout}>Logout</p>,
}
];