feat: Centralize authentication redirects to middleware, remove client-side redirect logic, and refine logout process.
This commit is contained in:
@@ -18,10 +18,11 @@ export default function AgentLayout({
|
||||
useEffect(() => {
|
||||
if (status === 'loading') return;
|
||||
|
||||
if (!session) {
|
||||
router.replace('/login');
|
||||
return;
|
||||
}
|
||||
// Don't redirect to /login here — the middleware handles that.
|
||||
// Doing it here causes race conditions during logout (layout detects
|
||||
// session loss and redirects to /login via client-side navigation,
|
||||
// which can conflict with the server-side logout redirect).
|
||||
if (!session) return;
|
||||
|
||||
// Redirect non-agents to user dashboard
|
||||
const userRole = (session.user as any)?.role;
|
||||
|
||||
Reference in New Issue
Block a user