fix e2e
This commit is contained in:
@@ -40,22 +40,19 @@ export default function LoginPage() {
|
||||
// Check if user is already authenticated
|
||||
useEffect(() => {
|
||||
if (session) {
|
||||
// If there's a returnTo parameter (user was redirected here from a protected route),
|
||||
// they might not have permission. Don't auto-redirect them back.
|
||||
const returnToParam = searchParams.get('returnTo');
|
||||
console.log('[LOGIN] returnToParam:', returnToParam);
|
||||
console.log('[LOGIN] returnTo:', returnTo);
|
||||
const hasReturnTo = returnToParam !== null;
|
||||
if (hasReturnTo) {
|
||||
console.log('[LOGIN] Has returnTo, setting insufficient permissions');
|
||||
// Check if this is a returnTo redirect (user lacks permissions)
|
||||
const isPermissionRedirect = searchParams.get('returnTo') !== null;
|
||||
|
||||
if (isPermissionRedirect) {
|
||||
// User was redirected here due to insufficient permissions
|
||||
// Show permission error instead of redirecting
|
||||
setHasInsufficientPermissions(true);
|
||||
} else {
|
||||
// No returnTo means they navigated here directly while authenticated
|
||||
console.log('[LOGIN] No returnTo, redirecting to dashboard');
|
||||
// User navigated here directly while authenticated, redirect to dashboard
|
||||
router.replace('/dashboard');
|
||||
}
|
||||
}
|
||||
}, [session, router, returnTo, searchParams]);
|
||||
}, [session, router, searchParams]);
|
||||
|
||||
// Use enhanced form hook
|
||||
const {
|
||||
|
||||
Reference in New Issue
Block a user