-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug-auth.html
More file actions
71 lines (61 loc) · 2.4 KB
/
debug-auth.html
File metadata and controls
71 lines (61 loc) · 2.4 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
<!DOCTYPE html>
<html>
<head>
<title>Auth Debug</title>
</head>
<body>
<h1>Authentication Debug</h1>
<button onclick="testAuth()">Test Auth Flow</button>
<button onclick="checkToken()">Check Token</button>
<button onclick="clearToken()">Clear Token</button>
<div id="output"></div>
<script>
function log(message) {
document.getElementById('output').innerHTML += '<p>' + message + '</p>';
}
function testAuth() {
log('🔍 Starting auth test...');
// Check URL parameters
const urlParams = new URLSearchParams(window.location.search);
const authSuccess = urlParams.get('auth_success');
const token = urlParams.get('token');
log('URL params: auth_success=' + authSuccess + ', hasToken=' + !!token);
if (authSuccess === 'true' && token) {
log('✅ Found token in URL, storing...');
localStorage.setItem('auth_token', token);
window.history.replaceState({}, document.title, window.location.pathname);
}
// Check stored token
const storedToken = localStorage.getItem('auth_token');
log('Stored token: ' + (storedToken ? 'YES' : 'NO'));
if (storedToken) {
// Test API call
fetch('http://localhost:3001/api/auth/me', {
headers: { 'Authorization': 'Bearer ' + storedToken },
credentials: 'include'
})
.then(response => {
log('API Response: ' + response.status + ' ' + response.statusText);
return response.json();
})
.then(data => {
log('API Data: ' + JSON.stringify(data));
})
.catch(error => {
log('API Error: ' + error.message);
});
}
}
function checkToken() {
const token = localStorage.getItem('auth_token');
log('Current token: ' + (token ? token.substring(0, 50) + '...' : 'NONE'));
}
function clearToken() {
localStorage.removeItem('auth_token');
log('Token cleared');
}
// Auto-run on load
window.onload = testAuth;
</script>
</body>
</html>