refactor: remove agent redirect from user dashboard layout to allow persistent access
This commit is contained in:
@@ -34,15 +34,10 @@ export default function UserLayout({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status === 'loading') return;
|
if (status === 'loading') return;
|
||||||
|
|
||||||
// Allow public pages without authentication
|
// Allow public pages without authentication.
|
||||||
|
// Agents are intentionally allowed to land on /user/dashboard — the logo
|
||||||
|
// points there for all roles, so this layout must not bounce them away.
|
||||||
if (isPublic) {
|
if (isPublic) {
|
||||||
// If logged in as agent, redirect to agent dashboard only from user dashboard
|
|
||||||
if (session && pathname === '/user/dashboard') {
|
|
||||||
const userRole = (session.user as any)?.role;
|
|
||||||
if (userRole === 'AGENT') {
|
|
||||||
router.replace('/agent/dashboard');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user