forked from nlweb-ai/NLWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_auth.html
More file actions
53 lines (47 loc) · 1.83 KB
/
debug_auth.html
File metadata and controls
53 lines (47 loc) · 1.83 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
<!DOCTYPE html>
<html>
<head>
<title>Debug Auth</title>
</head>
<body>
<h1>Debug Authentication</h1>
<button onclick="checkAuth()">Check Auth Status</button>
<button onclick="clearAuth()">Clear Auth & Reload</button>
<pre id="output"></pre>
<script>
function checkAuth() {
const authToken = localStorage.getItem('authToken');
const userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}');
let output = 'Auth Token: ' + (authToken ? authToken.substring(0, 50) + '...' : 'None') + '\n';
output += 'User Info: ' + JSON.stringify(userInfo, null, 2) + '\n\n';
if (authToken) {
// Try to decode JWT
try {
const parts = authToken.split('.');
if (parts.length === 3) {
const payload = JSON.parse(atob(parts[1]));
output += 'JWT Payload: ' + JSON.stringify(payload, null, 2) + '\n';
// Check expiration
if (payload.exp) {
const expDate = new Date(payload.exp * 1000);
const now = new Date();
output += '\nToken expires: ' + expDate + '\n';
output += 'Current time: ' + now + '\n';
output += 'Token valid: ' + (expDate > now) + '\n';
}
}
} catch (e) {
output += 'Error decoding JWT: ' + e.message;
}
}
document.getElementById('output').textContent = output;
}
function clearAuth() {
localStorage.removeItem('authToken');
localStorage.removeItem('userInfo');
alert('Auth cleared. Reloading page...');
window.location.reload();
}
</script>
</body>
</html>