Skip to content

Commit

Permalink
fix(client): fix logout issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lareii committed Sep 15, 2024
1 parent 0015138 commit cefbf53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/components/app/Navbar/Dropdown.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { cookies } from 'next/headers';
import Link from 'next/link';
import {
User,
Expand All @@ -22,16 +23,19 @@ import { useAuthStore } from '@/stores/auth';
import { logout } from '@/lib/api/auth';

export default function Dropdown({ router, pathname }) {
const cookieStore = cookies();
const user = useAuthStore((state) => state.user);
const setUser = useAuthStore((state) => state.setUser);

const isProfilePage =
pathname === `/app/users/${user?.username}` || pathname.startsWith('/app/settings');
pathname === `/app/users/${user?.username}` ||
pathname.startsWith('/app/settings');

const handleLogout = async (e) => {
e.preventDefault();

setUser('loading');
cookieStore.delete('jwt');
await logout();
router.push('/login');
router.refresh();
Expand Down

0 comments on commit cefbf53

Please sign in to comment.