-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug-auth.html
More file actions
121 lines (111 loc) · 4.82 KB
/
Copy pathdebug-auth.html
File metadata and controls
121 lines (111 loc) · 4.82 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html>
<head>
<title>Debug Authentication</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.test-section { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }
.success { background-color: #d4edda; border-color: #c3e6cb; }
.error { background-color: #f8d7da; border-color: #f5c6cb; }
.info { background-color: #d1ecf1; border-color: #bee5eb; }
button { padding: 10px 15px; margin: 5px; background: #007bff; color: white; border: none; border-radius: 3px; cursor: pointer; }
button:hover { background: #0056b3; }
#results { margin-top: 20px; }
</style>
</head>
<body>
<h1>🔍 Authentication Debug Tool</h1>
<div class="test-section info">
<h3>📋 Current Server Status</h3>
<p><strong>Server URL:</strong> <a href="http://localhost:3000" target="_blank">http://localhost:3000</a></p>
<p><strong>Environment:</strong> .env.local loaded</p>
<p><strong>NextAuth Secret:</strong> Configured</p>
</div>
<div class="test-section">
<h3>🧪 Test Authentication Flow</h3>
<button onclick="testServerConnection()">Test Server Connection</button>
<button onclick="testAuthEndpoint()">Test Auth Endpoint</button>
<button onclick="testUserCreation()">Test User Creation</button>
<button onclick="testUserLogin()">Test User Login</button>
</div>
<div class="test-section">
<h3>📝 Manual Test Steps</h3>
<ol>
<li>Go to <a href="http://localhost:3000/signup" target="_blank">Sign Up Page</a></li>
<li>Create a test account with:
<ul>
<li>Email: test@example.com</li>
<li>Password: testpassword123</li>
<li>Name: Test User</li>
</ul>
</li>
<li>Go to <a href="http://localhost:3000/login" target="_blank">Login Page</a></li>
<li>Try to sign in with the same credentials</li>
<li>Check browser console (F12) for any errors</li>
</ol>
</div>
<div id="results"></div>
<script>
function log(message, type = 'info') {
const results = document.getElementById('results');
const div = document.createElement('div');
div.className = `test-section ${type}`;
div.innerHTML = `<strong>${new Date().toLocaleTimeString()}:</strong> ${message}`;
results.appendChild(div);
}
async function testServerConnection() {
try {
const response = await fetch('http://localhost:3000/api/health');
const data = await response.json();
log(`✅ Server is running: ${JSON.stringify(data)}`, 'success');
} catch (error) {
log(`❌ Server connection failed: ${error.message}`, 'error');
}
}
async function testAuthEndpoint() {
try {
const response = await fetch('http://localhost:3000/api/auth/session');
const data = await response.json();
log(`✅ Auth endpoint accessible: ${JSON.stringify(data)}`, 'success');
} catch (error) {
log(`❌ Auth endpoint failed: ${error.message}`, 'error');
}
}
async function testUserCreation() {
try {
const response = await fetch('http://localhost:3000/api/auth/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'debug-test@example.com',
password: 'testpassword123',
name: 'Debug Test User'
})
});
const data = await response.json();
if (response.ok) {
log(`✅ User creation successful: ${JSON.stringify(data)}`, 'success');
} else {
log(`❌ User creation failed: ${JSON.stringify(data)}`, 'error');
}
} catch (error) {
log(`❌ User creation error: ${error.message}`, 'error');
}
}
async function testUserLogin() {
try {
const response = await fetch('http://localhost:3000/api/auth/session');
const data = await response.json();
log(`📊 Current session: ${JSON.stringify(data)}`, 'info');
} catch (error) {
log(`❌ Session check failed: ${error.message}`, 'error');
}
}
// Auto-run basic tests
window.onload = function() {
testServerConnection();
testAuthEndpoint();
};
</script>
</body>
</html>