feat: Centralize authentication redirects to middleware, remove client-side redirect logic, and refine logout process.

This commit is contained in:
pradeepkumar
2026-03-10 09:28:19 +05:30
parent 69eff70fbb
commit c7f1b89203
9 changed files with 77 additions and 70 deletions

View File

@@ -4,6 +4,7 @@ import { useState } from 'react';
import { useRouter } from 'next/navigation';
import { signIn } from 'next-auth/react';
import Link from 'next/link';
import { resetLogoutState } from '@/services/api';
export default function LoginPage() {
const router = useRouter();
@@ -13,9 +14,12 @@ export default function LoginPage() {
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
// Safety net: clear logout flag when login page loads
// Safety net: clear logout flags when login page loads.
// This resets both the localStorage flag and the module-level flag in api.ts
// so the API interceptor stops blocking requests.
if (typeof window !== 'undefined') {
localStorage.removeItem('isLoggingOut');
resetLogoutState();
}
const handleSubmit = async (e: React.FormEvent) => {