refactor: Centralize logout logic to a dedicated page, clear local storage, and prevent API requests during the process.
This commit is contained in:
@@ -4,7 +4,7 @@ import { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import Link from 'next/link';
|
||||
import Image from 'next/image';
|
||||
|
||||
import { useSession, signOut } from 'next-auth/react';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { agentsService } from '@/services/agents.service';
|
||||
import { usersService } from '@/services/users.service';
|
||||
import { uploadService } from '@/services/upload.service';
|
||||
@@ -295,7 +295,13 @@ export function CommonHeader() {
|
||||
|
||||
{/* Log Out */}
|
||||
<button
|
||||
onClick={() => signOut({ callbackUrl: '/login' })}
|
||||
onClick={() => {
|
||||
setShowProfileMenu(false);
|
||||
localStorage.removeItem('accessToken');
|
||||
localStorage.removeItem('refreshToken');
|
||||
localStorage.removeItem('user');
|
||||
window.location.href = '/logout';
|
||||
}}
|
||||
className="w-full flex items-center gap-3 px-4 py-3 hover:bg-black/5 transition-colors"
|
||||
>
|
||||
<Image
|
||||
|
||||
Reference in New Issue
Block a user