middleware fix wip

This commit is contained in:
2026-01-04 23:02:28 +01:00
parent 691e6e2c7e
commit cd3d9ae34f
8 changed files with 74 additions and 13 deletions

View File

@@ -227,8 +227,11 @@ export function handleAuthFlow(
return { shouldRedirect: false, shouldShowPage: true };
case AuthActionType.SHOW_PERMISSION_ERROR:
const errorUrl = router.getLoginRedirectUrl();
logger.info('[handleAuthFlow] Returning SHOW_PERMISSION_ERROR', { errorUrl });
return { shouldRedirect: true, redirectUrl: errorUrl };
// Redirect to user's home page instead of login (they're already logged in)
const homeUrl = session?.role === 'sponsor' ? routes.sponsor.dashboard :
session?.role === 'admin' ? routes.admin.root :
routes.protected.dashboard;
logger.info('[handleAuthFlow] Returning SHOW_PERMISSION_ERROR, redirecting to home', { homeUrl, userRole: session?.role });
return { shouldRedirect: true, redirectUrl: homeUrl };
}
}