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 {
|
||||
|
||||
@@ -88,8 +88,6 @@ test.describe('Website Pages - TypeORM Integration', () => {
|
||||
{
|
||||
const auth = await WebsiteAuthManager.createAuthContext(browser, request, 'auth');
|
||||
await auth.page.goto(`${WEBSITE_BASE_URL}${path}`);
|
||||
console.log(`[TEST] Final URL after goto: ${auth.page.url()}`);
|
||||
console.log(`[TEST] Expected to include 'login', actual includes: ${auth.page.url().includes('login')}`);
|
||||
expect(auth.page.url().includes('login')).toBeTruthy();
|
||||
await auth.context.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user