Major improvements: - Created startup orchestration system with health monitoring and graceful shutdown - Fixed user registration and login with simplified authentication flow - Rebuilt authentication forms from scratch with direct API integration - Implemented comprehensive debugging and error handling - Added Redis fallback functionality for disabled environments - Fixed CORS configuration for cross-origin frontend requests - Simplified password validation to 6+ characters (removed complexity requirements) - Added toast notifications at app level for better UX feedback - Created comprehensive startup/shutdown scripts with OODA methodology - Fixed database validation and connection issues - Implemented TokenService memory fallback when Redis is disabled Technical details: - New SimpleLoginForm.tsx and SimpleRegisterForm.tsx components - Enhanced CORS middleware with additional allowed origins - Simplified auth validators and removed strict password requirements - Added extensive logging and diagnostic capabilities - Fixed authentication middleware token validation - Implemented graceful Redis error handling throughout the stack - Created modular startup system with configurable health checks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
224 lines
No EOL
7.1 KiB
HTML
224 lines
No EOL
7.1 KiB
HTML
<\!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Shattered Void - Auth Test</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
background-color: #1a1a1a;
|
|
color: #fff;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
label {
|
|
display: block;
|
|
margin-bottom: 5px;
|
|
color: #ccc;
|
|
}
|
|
input {
|
|
width: 100%;
|
|
padding: 10px;
|
|
border: 1px solid #555;
|
|
background-color: #333;
|
|
color: #fff;
|
|
border-radius: 4px;
|
|
}
|
|
button {
|
|
background-color: #4CAF50;
|
|
color: white;
|
|
padding: 10px 20px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
margin-right: 10px;
|
|
}
|
|
button:hover {
|
|
background-color: #45a049;
|
|
}
|
|
.status {
|
|
margin-top: 20px;
|
|
padding: 10px;
|
|
border-radius: 4px;
|
|
}
|
|
.success {
|
|
background-color: #4CAF50;
|
|
}
|
|
.error {
|
|
background-color: #f44336;
|
|
}
|
|
.response {
|
|
background-color: #333;
|
|
padding: 10px;
|
|
border-radius: 4px;
|
|
margin-top: 10px;
|
|
white-space: pre-wrap;
|
|
font-family: monospace;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>🌌 Shattered Void - Authentication Test</h1>
|
|
|
|
<div>
|
|
<h2>Registration</h2>
|
|
<div class="form-group">
|
|
<label for="regEmail">Email:</label>
|
|
<input type="email" id="regEmail" value="test3@example.com">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="regUsername">Username:</label>
|
|
<input type="text" id="regUsername" value="testuser789">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="regPassword">Password:</label>
|
|
<input type="password" id="regPassword" value="TestPass3@">
|
|
</div>
|
|
<button onclick="register()">Register</button>
|
|
</div>
|
|
|
|
<div>
|
|
<h2>Login</h2>
|
|
<div class="form-group">
|
|
<label for="loginEmail">Email:</label>
|
|
<input type="email" id="loginEmail" value="test@example.com">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="loginPassword">Password:</label>
|
|
<input type="password" id="loginPassword" value="TestPass1@">
|
|
</div>
|
|
<button onclick="login()">Login</button>
|
|
</div>
|
|
|
|
<div>
|
|
<h2>User Profile (requires login)</h2>
|
|
<button onclick="getProfile()">Get Profile</button>
|
|
<button onclick="logout()">Logout</button>
|
|
</div>
|
|
|
|
<div id="status"></div>
|
|
|
|
<script>
|
|
const API_BASE = 'http://localhost:3000';
|
|
let authToken = localStorage.getItem('auth_token');
|
|
|
|
function showStatus(message, isError = false, response = null) {
|
|
const statusDiv = document.getElementById('status');
|
|
statusDiv.innerHTML = `
|
|
<div class="status ${isError ? 'error' : 'success'}">
|
|
${message}
|
|
</div>
|
|
${response ? `<div class="response">${JSON.stringify(response, null, 2)}</div>` : ''}
|
|
`;
|
|
}
|
|
|
|
async function apiCall(endpoint, method = 'GET', data = null) {
|
|
const options = {
|
|
method,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
};
|
|
|
|
if (authToken) {
|
|
options.headers.Authorization = `Bearer ${authToken}`;
|
|
}
|
|
|
|
if (data) {
|
|
options.body = JSON.stringify(data);
|
|
}
|
|
|
|
try {
|
|
const response = await fetch(`${API_BASE}${endpoint}`, options);
|
|
const result = await response.json();
|
|
|
|
if (response.ok && result.success) {
|
|
return { success: true, data: result };
|
|
} else {
|
|
return { success: false, error: result.message || result.error || 'Unknown error', data: result };
|
|
}
|
|
} catch (error) {
|
|
return { success: false, error: error.message, data: null };
|
|
}
|
|
}
|
|
|
|
async function register() {
|
|
const email = document.getElementById('regEmail').value;
|
|
const username = document.getElementById('regUsername').value;
|
|
const password = document.getElementById('regPassword').value;
|
|
|
|
const result = await apiCall('/api/auth/register', 'POST', {
|
|
email,
|
|
username,
|
|
password
|
|
});
|
|
|
|
if (result.success) {
|
|
authToken = result.data.data.token;
|
|
localStorage.setItem('auth_token', authToken);
|
|
localStorage.setItem('user_data', JSON.stringify(result.data.data.user));
|
|
showStatus('Registration successful\!', false, result.data);
|
|
} else {
|
|
showStatus(`Registration failed: ${result.error}`, true, result.data);
|
|
}
|
|
}
|
|
|
|
async function login() {
|
|
const email = document.getElementById('loginEmail').value;
|
|
const password = document.getElementById('loginPassword').value;
|
|
|
|
const result = await apiCall('/api/auth/login', 'POST', {
|
|
email,
|
|
password
|
|
});
|
|
|
|
if (result.success) {
|
|
authToken = result.data.data.token;
|
|
localStorage.setItem('auth_token', authToken);
|
|
localStorage.setItem('user_data', JSON.stringify(result.data.data.user));
|
|
showStatus('Login successful\!', false, result.data);
|
|
} else {
|
|
showStatus(`Login failed: ${result.error}`, true, result.data);
|
|
}
|
|
}
|
|
|
|
async function getProfile() {
|
|
if (\!authToken) {
|
|
showStatus('Please login first', true);
|
|
return;
|
|
}
|
|
|
|
const result = await apiCall('/api/auth/verify', 'GET');
|
|
|
|
if (result.success) {
|
|
showStatus('Profile retrieved successfully\!', false, result.data);
|
|
} else {
|
|
showStatus(`Failed to get profile: ${result.error}`, true, result.data);
|
|
}
|
|
}
|
|
|
|
async function logout() {
|
|
const result = await apiCall('/api/auth/logout', 'POST');
|
|
|
|
authToken = null;
|
|
localStorage.removeItem('auth_token');
|
|
localStorage.removeItem('user_data');
|
|
|
|
showStatus('Logged out successfully\!', false, result.data);
|
|
}
|
|
|
|
// Check if user is already logged in
|
|
if (authToken) {
|
|
const userData = localStorage.getItem('user_data');
|
|
if (userData) {
|
|
showStatus(`Already logged in as: ${JSON.parse(userData).username}`, false);
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |