remove demo code
This commit is contained in:
@@ -22,8 +22,8 @@ export async function setWebsiteAuthContext(
|
||||
const base = { domain, path: '/' };
|
||||
|
||||
// The website uses `gp_session` cookie for authentication
|
||||
// For smoke tests, we now use demo login API to get real session cookies
|
||||
// instead of static cookie values
|
||||
// For smoke tests, we use normal login API with seeded demo user credentials
|
||||
// to get real session cookies
|
||||
|
||||
if (auth === 'public') {
|
||||
// No authentication needed
|
||||
@@ -31,46 +31,33 @@ export async function setWebsiteAuthContext(
|
||||
return;
|
||||
}
|
||||
|
||||
// For authenticated contexts, we need to perform a demo login
|
||||
// For authenticated contexts, we need to perform a normal login
|
||||
// This ensures we get real session cookies with proper structure
|
||||
// Note: All auth contexts use the same seeded demo driver user for simplicity
|
||||
// Role-based access control is tested separately in integration tests
|
||||
|
||||
// Determine which demo role to use based on auth context
|
||||
let demoRole: string;
|
||||
switch (auth) {
|
||||
case 'sponsor':
|
||||
demoRole = 'sponsor';
|
||||
break;
|
||||
case 'admin':
|
||||
demoRole = 'league-admin'; // Real admin role from AuthSessionDTO
|
||||
break;
|
||||
case 'auth':
|
||||
default:
|
||||
demoRole = 'driver';
|
||||
break;
|
||||
}
|
||||
|
||||
// Call the demo login API directly (not through Next.js rewrite)
|
||||
// This bypasses any proxy/cookie issues
|
||||
const response = await fetch('http://localhost:3101/auth/demo-login', {
|
||||
// Call the normal login API with seeded demo user credentials
|
||||
// Use demo.driver@example.com for all auth contexts (driver role)
|
||||
const response = await fetch('http://localhost:3101/auth/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
role: demoRole,
|
||||
rememberMe: true
|
||||
email: 'demo.driver@example.com',
|
||||
password: 'Demo1234!',
|
||||
}),
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Demo login failed: ${response.status}`);
|
||||
throw new Error(`Normal login failed: ${response.status}`);
|
||||
}
|
||||
|
||||
// Extract cookies from the response
|
||||
const setCookieHeader = response.headers.get('set-cookie');
|
||||
if (!setCookieHeader) {
|
||||
throw new Error('No cookies set by demo login');
|
||||
throw new Error('No cookies set by normal login');
|
||||
}
|
||||
|
||||
// Parse the Set-Cookie headers
|
||||
|
||||
Reference in New Issue
Block a user