-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_user_auth.php
More file actions
105 lines (84 loc) · 2.94 KB
/
debug_user_auth.php
File metadata and controls
105 lines (84 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
// Debug script to isolate the user authentication issue
$baseUrl = 'http://127.0.0.1:8000/api';
// User credentials
$userCredentials = [
'user_code' => 'test123',
'password' => 'password123'
];
echo "=== DEBUGGING USER AUTHENTICATION ISSUE ===\n\n";
// Get user token
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "$baseUrl/user/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($userCredentials),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Accept: application/json'
]
]);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($httpCode === 200) {
$data = json_decode($response, true);
$token = $data['access_token'];
echo "✅ User login successful\n";
echo "Testing individual endpoints with timeout protection...\n\n";
// Test with shorter timeout
$endpoints = [
'/chat/users/search?q=test' => 'Search Users (should work)',
];
foreach ($endpoints as $endpoint => $description) {
echo "Testing: $description... ";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "$baseUrl$endpoint",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5, // 5 second timeout
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $token",
'Accept: application/json'
]
]);
$result = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($result === false) {
echo "❌ TIMEOUT or ERROR\n";
} else {
echo "✅ SUCCESS ($code)\n";
}
}
echo "\nTesting problematic endpoints with very short timeout...\n";
$problematicEndpoints = [
'/chat/groups' => 'Get Groups (causes timeout)',
'/chat/unread-counts' => 'Unread Counts (causes timeout)'
];
foreach ($problematicEndpoints as $endpoint => $description) {
echo "Testing: $description... ";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "$baseUrl$endpoint",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 2, // Very short timeout
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $token",
'Accept: application/json'
]
]);
$result = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if (curl_errno($curl)) {
echo "❌ TIMEOUT/ERROR: " . curl_error($curl) . "\n";
} else {
echo "✅ SUCCESS ($code) - " . substr($result, 0, 100) . "...\n";
}
curl_close($curl);
}
} else {
echo "❌ User login failed: $response\n";
}
echo "\n=== END DEBUG ===\n";