This commit is contained in:
2025-07-19 12:21:46 +02:00
parent 12822dfdbf
commit 2e7957d0a0
86 changed files with 25573 additions and 0 deletions

44
scripts/testEnvLogin.js Normal file
View File

@@ -0,0 +1,44 @@
const fetch = require('node-fetch');
async function testEnvLogin() {
try {
console.log('Testing admin login with .env credentials...');
console.log('Username: admin, Password: 0000');
const loginRes = await fetch('http://localhost:4000/api/admin/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
username: 'admin',
password: '0000'
})
});
console.log('Response status:', loginRes.status);
const data = await loginRes.json();
console.log('Response data:', data);
if (loginRes.ok) {
console.log('✅ Login successful! Token received');
// Test the token by calling a protected endpoint
console.log('Testing protected endpoint...');
const teamsRes = await fetch('http://localhost:4000/api/teams', {
headers: { 'Authorization': `Bearer ${data.token}` }
});
if (teamsRes.ok) {
const teams = await teamsRes.json();
console.log(`✅ Token works! Found ${teams.length} teams`);
} else {
console.log('❌ Token validation failed');
}
} else {
console.log('❌ Login failed:', data.error);
}
} catch (err) {
console.error('Error:', err.message);
}
}
testEnvLogin();