fix e2e
This commit is contained in:
@@ -40,22 +40,19 @@ export default function LoginPage() {
|
|||||||
// Check if user is already authenticated
|
// Check if user is already authenticated
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (session) {
|
if (session) {
|
||||||
// If there's a returnTo parameter (user was redirected here from a protected route),
|
// Check if this is a returnTo redirect (user lacks permissions)
|
||||||
// they might not have permission. Don't auto-redirect them back.
|
const isPermissionRedirect = searchParams.get('returnTo') !== null;
|
||||||
const returnToParam = searchParams.get('returnTo');
|
|
||||||
console.log('[LOGIN] returnToParam:', returnToParam);
|
if (isPermissionRedirect) {
|
||||||
console.log('[LOGIN] returnTo:', returnTo);
|
// User was redirected here due to insufficient permissions
|
||||||
const hasReturnTo = returnToParam !== null;
|
// Show permission error instead of redirecting
|
||||||
if (hasReturnTo) {
|
|
||||||
console.log('[LOGIN] Has returnTo, setting insufficient permissions');
|
|
||||||
setHasInsufficientPermissions(true);
|
setHasInsufficientPermissions(true);
|
||||||
} else {
|
} else {
|
||||||
// No returnTo means they navigated here directly while authenticated
|
// User navigated here directly while authenticated, redirect to dashboard
|
||||||
console.log('[LOGIN] No returnTo, redirecting to dashboard');
|
|
||||||
router.replace('/dashboard');
|
router.replace('/dashboard');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [session, router, returnTo, searchParams]);
|
}, [session, router, searchParams]);
|
||||||
|
|
||||||
// Use enhanced form hook
|
// Use enhanced form hook
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -88,8 +88,6 @@ test.describe('Website Pages - TypeORM Integration', () => {
|
|||||||
{
|
{
|
||||||
const auth = await WebsiteAuthManager.createAuthContext(browser, request, 'auth');
|
const auth = await WebsiteAuthManager.createAuthContext(browser, request, 'auth');
|
||||||
await auth.page.goto(`${WEBSITE_BASE_URL}${path}`);
|
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();
|
expect(auth.page.url().includes('login')).toBeTruthy();
|
||||||
await auth.context.close();
|
await auth.context.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user