2026-02-18 00:50:38 +05:30
|
|
|
'use client';
|
|
|
|
|
|
2026-03-08 01:55:46 +05:30
|
|
|
import { useEffect, useRef } from 'react';
|
2026-03-10 11:49:33 +05:30
|
|
|
import { clearAuthCookies } from './actions';
|
|
|
|
|
import { signOut } from 'next-auth/react';
|
2026-03-10 22:48:10 +05:30
|
|
|
import Image from 'next/image';
|
2026-02-18 00:50:38 +05:30
|
|
|
|
|
|
|
|
export default function LogoutPage() {
|
2026-03-08 01:55:46 +05:30
|
|
|
const hasStarted = useRef(false);
|
|
|
|
|
|
2026-02-18 00:50:38 +05:30
|
|
|
useEffect(() => {
|
2026-03-08 01:55:46 +05:30
|
|
|
if (hasStarted.current) return;
|
|
|
|
|
hasStarted.current = true;
|
|
|
|
|
|
2026-03-10 00:14:43 +05:30
|
|
|
const performLogout = async () => {
|
2026-03-10 11:49:33 +05:30
|
|
|
// Clear localStorage
|
2026-03-10 00:14:43 +05:30
|
|
|
localStorage.setItem('isLoggingOut', 'true');
|
|
|
|
|
localStorage.removeItem('accessToken');
|
|
|
|
|
localStorage.removeItem('refreshToken');
|
|
|
|
|
localStorage.removeItem('user');
|
|
|
|
|
|
2026-03-10 22:48:10 +05:30
|
|
|
await signOut({ redirect: false });
|
2026-03-10 11:49:33 +05:30
|
|
|
// Delete httpOnly cookies via server action (Next.js cookies() API)
|
|
|
|
|
await clearAuthCookies();
|
2026-03-10 09:28:19 +05:30
|
|
|
|
2026-03-16 13:25:32 +05:30
|
|
|
// Redirect to login immediately
|
|
|
|
|
window.location.href = '/login';
|
2026-03-10 00:14:43 +05:30
|
|
|
};
|
|
|
|
|
|
2026-03-10 11:49:33 +05:30
|
|
|
performLogout().catch(() => {
|
|
|
|
|
window.location.href = '/login';
|
|
|
|
|
});
|
2026-02-18 00:50:38 +05:30
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return (
|
2026-03-10 22:48:10 +05:30
|
|
|
<div
|
|
|
|
|
className="min-h-screen flex flex-col items-center justify-center"
|
|
|
|
|
style={{
|
|
|
|
|
background: 'linear-gradient(to bottom, #c4d9d4, #f0f5fc)',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Image
|
|
|
|
|
src="/assets/images/splash-house.png"
|
|
|
|
|
alt="House illustration"
|
|
|
|
|
width={150}
|
|
|
|
|
height={108}
|
|
|
|
|
priority
|
|
|
|
|
/>
|
|
|
|
|
<div className="mt-[35px]">
|
|
|
|
|
<Image
|
|
|
|
|
src="/assets/images/splash-logo.png"
|
|
|
|
|
alt="RE-Quest logo"
|
|
|
|
|
width={264}
|
|
|
|
|
height={55}
|
|
|
|
|
priority
|
|
|
|
|
/>
|
2026-02-18 00:50:38 +05:30
|
|
|
</div>
|
2026-03-10 22:48:10 +05:30
|
|
|
<p className="mt-8 font-serif text-[14px] text-[#00293D]/60 animate-pulse">
|
|
|
|
|
Signing out...
|
|
|
|
|
</p>
|
2026-02-18 00:50:38 +05:30
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|